Code Comments
Programming Forum and web based access to our favorite programming groups.Really quick question. In Perl, if I open a file in notepad system( "notepad.exe $file" ) ; Perl stops processes and will not continue until I close notpad. How can I open the file, and have Perl continue running?
Post Follow-up to this messagehttp://perldoc.perl.org/functions/system.html ... the parent process waits for the child process to complete. The return value is the exit status of the program as returned by the wait c all. You want to first fork and run the command in its own thread. http://perldoc.perl.org/functions/fork.html $val = fork; if ( not defined $val ) { print "Fork failed" } elsif ($val == 0) { system('notepad.exe'); exit; } ...
Post Follow-up to this messageinthepickle wrote: > > Really quick question. In Perl, if I open a file in notepad > system( "notepad.exe $file" ) ; > Perl stops processes and will not continue until I close notpad. > How can I open the file, and have Perl continue running? Quick question, slow answer. Perl will either spawn a shell subprocess and wait for it to complete (using the system() call as you have described) or start a process and exit (using a call to exec()). You may want to take a look at calling fork(), but starting a process from another process leaves the parent with a big responsibility, and it's more likely that your Perl program should simply complete all that it has to do and then exec "notepad $file"; when it is about to terminate. HTH, Rob
Post Follow-up to this messageFrom: inthepickle <inthepickle@gmail.com> > Really quick question. In Perl, if I open a file in notepad > system( "notepad.exe $file" ) ; > Perl stops processes and will not continue until I close notpad. > How can I open the file, and have Perl continue running? system(1, 'notepad.exe', $file) Jenda ===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery
Post Follow-up to this messageJenda Krynicky wrote: > > From: inthepickle <inthepickle@gmail.com> > > > system(1, 'notepad.exe', $file) Is that documented anywhere Jenda? Rob
Post Follow-up to this messageFrom: Rob Dixon <rob.dixon@gmx.com> > Jenda Krynicky wrote: > > Is that documented anywhere Jenda? > > Rob perldoc perlport in the "Alphabetical Listing of Perl Functions" section under "system". Jenda ===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.