I need to execute DOS level commands from perl and I must be able to test
for success.
I've found the system() function and it seems to work except I'm having
problems getting the correct error return back.

To test the error return I've created this very simple code.  In it I try
everything I know to get the error return back with no success.  The correct
error return value for this should be a 4.  Any suggestions on how I can
execute a DOS command and get the error return back would be greatly
appreciated.

thanks, BobG.

# errorcode.pl
# generate an error to test the return,

use Win32;

@cmd = ("xcopy","ThisFileDoesNotExist", "foo.out" );

$return = system(@cmd);   ##### The return code for xcopy should be 4.

print "The return code for xcopy should be 4.\n";
print "return = $return\n";
print "? = $?\n";
print "getlasterror = ";
print (  Win32::GetLastError());
print "\nFormated error = ";
print ( Win32::FormatMessage (Win32::GetLastError()));



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to