Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > trying to execute 'at now + 2 minutes...

Reply
Thread Tools

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

 
 
mmccaws2
Guest
Posts: n/a
 
      03-17-2008
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
 
Reply With Quote
 
 
 
 
Randal L. Schwartz
Guest
Posts: n/a
 
      03-17-2008
>>>>> "mmccaws2" == mmccaws2 <(E-Mail Removed)> writes:

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
<(E-Mail Removed)> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
 
Reply With Quote
 
 
 
 
sandy_saydakov@yahoo.com
Guest
Posts: n/a
 
      03-17-2008
On 17 Mar, 08:10, mmccaws2 <(E-Mail Removed)> wrote:
>
> 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/
 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-17-2008
mmccaws2 <(E-Mail Removed)> 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.
 
Reply With Quote
 
mmccaws2
Guest
Posts: n/a
 
      03-17-2008
On Mar 17, 8:51 am, (E-Mail Removed) wrote:
> mmccaws2 <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IIS trying to execute a page under 1.1 Michael Carr ASP .Net 4 10-31-2005 07:38 PM
i am trying to Execute some command Bar Button but doesn't work =?Utf-8?B?ZG9ybGluZw==?= ASP .Net 0 06-23-2005 11:08 PM
Trying to Execute a file using exec master.dbo.xp_cmdshell, from ASP Me ASP General 3 11-30-2004 07:12 PM
Can i execute aspx file in my asp pag with server.execute method(sorry) Savas Ates ASP General 1 08-17-2004 04:52 PM
Trying to execute a function *following* RESET clearing the textfields... Charles M. Fish, Sr. Javascript 3 09-24-2003 06:53 PM



Advertisments