CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
about exec command

 



babyBlue
Novice

Nov 3, 2004, 1:24 PM

Post #1 of 3 (661 views)
about exec command Can't Post

Hello all,

I am writing a perl script which is always running and keep check for new arrived files. One new files arrives, it will first uninstall the previous version and then start install the new version.
while(1)
{
$newVersion = check if new version arrives();

if($newVersion)
{
exec($unInstallCommand);
exec($installCommand);
}

}

I am using exec to execute the uninstall and install, but after the unInstall finishes, the perl script exit from the while loop, which is not what I want. If I use System instead of exec command, how can I ensure the install starts after the completion of uninstall?

Thanks for any advices.


KevinR
Veteran


Nov 3, 2004, 2:58 PM

Post #2 of 3 (660 views)
Re: [babyBlue] about exec command [In reply to] Can't Post

you probably want to use system instead of exec. See perldoc:

list of Perl functions:

http://www.perldoc.com/perl5.8.4/pod/perlfunc.html#Alphabetical-Listing-of-Perl-Functions


system function:

http://www.perldoc.com/perl5.8.4/pod/func/system.html
-------------------------------------------------


(This post was edited by KevinR on Nov 3, 2004, 2:59 PM)


davorg
Thaumaturge / Moderator

Nov 4, 2004, 5:21 AM

Post #3 of 3 (653 views)
Re: [babyBlue] about exec command [In reply to] Can't Post

As KevinR says, you certainly want "system" and not "exec". "exec" will replace the current process (i.e. your program) with the new program. Which is what you are seeing and not what you want.

And as "system" doesn't return until the command has completed, there won't be a problem with your installation starting before uninstallation has finished.

I'd recommend reading the documentation of the functions that you want to use.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives