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

R

Randal L. Schwartz

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

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 :)
 
X

xhoster

mmccaws2 said:
Hi

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


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.
 
M

mmccaws2

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top