Click here to get back home

trying to execute 'at now + 2 minutes...

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
trying to execute 'at now + 2 minutes... mmccaws2 03-17-2008
Posted by mmccaws2 on March 17, 2008, 11:10 am
Please log in for more thread options
Hi

On unix I'll run a command at the command line like

> at now + 2 minutes
> ./trial.pl &
> Ctrl d

how do I do this from within a script?

Thanks
Mike

Posted by Randal L. Schwartz on March 17, 2008, 11:37 am
Please log in for more thread options

mmccaws2> Hi
mmccaws2> On unix I'll run a command at the command line like

>> at now + 2 minutes
>> ./trial.pl &
>> Ctrl d

mmccaws2> how do I do this from within a script?

open AT, "|at now + 2 minutes" or die $!;
print AT "./trial.pl"; # not sure why you backgrounded that.
close AT;

Or, if you don't really need "at", and you just want to execute something
in two minutes, you can simply fork:

defined(my $kid = fork) or die "Cannot fork: $!";
unless ($kid) { # child does...
sleep 2 * 60; # two minutes, measured in seconds
exec "./trial.pl"; # for example, or just do it in line
exit 0;
}

$kid's pid will show up on a waitpid() call later, so you need to wait for it
eventually or exit soon, or you can double fork and wait if you don't want the
zombie.

print "Just another Perl hacker,"; # the original, #0 :)

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Posted by sandy_saydakov on March 17, 2008, 11:45 am
Please log in for more thread options
>
> On unix I'll run a command at the command line like
>
> > at now + 2 minutes
> > ./trial.pl &
> > Ctrl d
>
> how do I do this from within a script?

Perhaps, sleep($seconds) first would do it for you.

/sandy
http://myperlquiz.com/

Posted by xhoster on March 17, 2008, 11:51 am
Please log in for more thread options
> Hi
>
> On unix I'll run a command at the command line like
>
> > at now + 2 minutes
> > ./trial.pl &
> > Ctrl d
>
> how do I do this from within a script?

open my $at, "| at now + 2 minutes" or die $!;
print $at './trial.pl&';
close $at or die $!;

Or you could do it strictly in Perl using fork and sleep and exec.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Posted by mmccaws2 on March 17, 2008, 12:10 pm
Please log in for more thread options
On Mar 17, 8:51 am, xhos...@gmail.com wrote:
> > Hi
>
> > On unix I'll run a command at the command line like
>
> > > at now + 2 minutes
> > > ./trial.pl &
> > > Ctrl d
>
> > how do I do this from within a script?
>
> open my $at, "| at now + 2 minutes" or die $!;
> print $at './trial.pl&';
> close $at or die $!;
>
> Or you could do it strictly in Perl using fork and sleep and exec.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> The costs of publication of this article were defrayed in part by the
> payment of page charges. This article must therefore be hereby marked
> advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
> this fact.

Thanks everyone

it works great.

Mike

Similar ThreadsPosted
HOW TO MAKE $1000+ IN 5 MINUTES January 15, 2008, 4:29 pm
Please take 5-10 minutes to help me on my thesis questionnaire and get the report June 18, 2007, 6:00 pm
Embperl Execute August 30, 2005, 1:37 pm
can't execute @SNMPGET@ on os/x box? August 16, 2006, 8:01 pm
How to get module to execute as standalone. April 10, 2006, 7:50 am
how to execute 30 transactions at a time November 20, 2006, 6:50 am
print command in qx// and execute it December 5, 2006, 9:05 am
How to execute a SQL select???? (successfully that is!) April 24, 2007, 5:11 pm
DBI; error in $handle->execute() December 4, 2007, 5:21 am
DCFORUM won't execute file as script July 26, 2005, 8:10 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap