in reply to Re: call exe on windows via script
in thread call exe on windows via script

I tried your method but it didn't work.
I am now getting an exit code of 256 from the system call.

I am not using strict or warnings. Can I just use warnings and not have to use strict yet ?

Thanks

Replies are listed 'Best First'.
Re^3: call exe on windows via script
by radiantmatrix (Parson) on Jul 11, 2005 at 14:16 UTC

    The reason using strict and warnings is useful is that it helps to ensure that the problem you're having is not actually a problem somewhere else in your script. Making your scripts work with both strict and warnings turned on means that if you are still having the same problem, you've isolated it properly. Otherwise you're shooting in the dark a bit.

    Also, it seems as though you didn't read the perlfunc secion on system() as I suggested, or you would have pasted output from a block like this:

    if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; }

    That is a very good and reliable way to find the "real" exit code. It may be that your application is being called correctly, but when called from Perl doesn't have access to the same environment, or a myriad other possibilities. When foo.exe exits, you can read it's docs to find the meaning of that exit code and thereby find the problem.

    However, until your code works with strict and warnings, you are probably just wasting debugging time.

    Larry Wall is Yoda: there is no try{}
    The Code that can be seen is not the true Code
      Thanks for the reply.
      Using my 'debugging' skills, I found the problem without the need for strict and warning on.
      Though I intend to have this in place before the script is used in a production manner.
      Actually I have read numerous articles on the system() command and have found that dividing the error code by 256 gives the true error code.
      However thanks to all who have replied, it has been most helpful.