Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Perl Background processes in Windows

by gepebril69 (Beadle)
on Jan 31, 2012 at 09:49 UTC ( #950917=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl Background processes in Windows
in thread Perl Background processes in Windows

@ Peter Dragon, Did you ever test your script? It can never work as the script starts with a die........


Comment on Re^2: Perl Background processes in Windows
Replies are listed 'Best First'.
Re^3: Perl Background processes in Windows
by Anonymous Monk on Jan 31, 2012 at 09:54 UTC

    @ Peter Dragon, Did you ever test your script? It can never work as the script starts with a die........

    A conditional die, makes all the difference in the world

    $ perl -le " die 6 if 9 " 6 at -e line 1. $ perl -le " die 6 if not 9 ; die 8 " 8 at -e line 1.
      @Peter Dragon, You are right. Maybe I posted to quickly, but no matter what $cmd I use (dir|date|xxxx.exe) it will always fail on my Windows7 x64 machine. It looks very strange to me that you can use a system call in that way. Normally you use something like `$cmd` or system() to execute a system call.

        Consider looking at perlop to see what -x does. Also, if it "always fails" (and you're interested in learning why), consider posting full code.

        Please note that dir and date are shell builtins in cmd.exe and thus never pass -x, because they are not programs that can be run. Also note that -x expects the full path to an executable and does not search $ENV{PATH}. Whether that is desired or not in the context of the above program, I don't know. Update: As the argument is passed to Win32::Process::Create(...), it makes sense to have a fully specified path, because that's what Win32::Process::Create() likely wants.

        >perl -wle "print $_, -x $_ ? ' yes':' no' for @ARGV" cmd.exe c:\WINDO +WS\system32\cmd.exe cmd.exe no c:\WINDOWS\system32\cmd.exe yes

        As to using system or backticks, these do not launch a background process. Which seems to be the purpose of the code under discussion. Actually, perlport points out system(1, ...) for launching a process in the background under Windows and OS/2.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2015-07-08 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls