Re: windows program return values vs perl return values from a call to system() -- windows post only



Purl Gurl wrote:
Purl Gurl wrote:
Fred wrote:

(snipped)

Without a die, your original code will return
a zero success, then execute your else block
which indicates notepad ran successfully,
when actually a "Bad command or file name"
error message is generated.

Different program logic for you,

#!perl

@Array = qw (notepad.exe c:/bad/path/to/notepad.exe);

for $execute (@Array)
 {
  $stat = system ($execute);

  if (!($!))
   { print "Notepad executed, COMMAND return code: $stat\n"; }
  else
   { print "GAK! I Am Dying: "; die $!; }
 }


C:\APACHE\USERS\TEST>perl test.pl Notepad executed, COMMAND return code: 0 GAK! I Am Dying: No such file or directory at test.pl line 12.


Purl Gurl

.



Relevant Pages

  • Re: how to let batch file to run two pgm wihtout waiting for first
    ... c:\a.txt and c:\b.txt so that I can switch between the two, what option or command can I execute to let this happen only for this batch file's execution? ... notepad c:\a.txt ...
    (microsoft.public.windowsxp.help_and_support)
  • [Full-Disclosure] Advanced usage of system() function.
    ... and call its arguments as a command for shell. ... as we can see we still didnt get what we want (typing exit ... Connection closed by foreign host. ... think what we want to execute. ...
    (Full-Disclosure)
  • Advanced usage of system() function.
    ... and call its arguments as a command for shell. ... as we can see we still didnt get what we want (typing exit we are ... Connection closed by foreign host. ... think what we want to execute. ...
    (Bugtraq)
  • Re: Wait for background processes to complete
    ... To be able to execute commands in the background and wait for their ... The documentation I am referring to is http://perldoc.perl.org/. ... You can run a command in the background with: ... There is a general problem with perl documentation: ...
    (comp.lang.perl.misc)
  • Execute Process Task not failing, but not executing the batch comm
    ... I can execute the following command from the windows "Run" prompt and it ... Might I have something set weird in SQL Server? ... server being by default configured to run as localsystem account, ...
    (microsoft.public.sqlserver.dts)