I'm running a command on loads of NT boxes to map a drive. Sometimes it fails. Actually loads of times it fails (I love NT) for lots of different reasons - I'm trying to get the error produced so I can fix them but having loads of difficulty. I wrote the following test to test what error is produces
undef $^E;
undef $!;
undef $?;
print "using system \n";
system("net use v: \\\\SERVERNAME\\SHARENAME");
print "dollar caret E reports $^E \n";
print "dollar Exclamation mark reports $! \n";
print "dollar question mark reports $? \n";
print "using backticks \n";
`net use v: \\\\SERVERNAME\\SHARENAME`;
print "dollar caret E reports $^E \n";
print "dollar Exclamation mark reports $! \n";
print "dollar question mark reports $? \n";
What I get is this (I'v formatted it a bit to make it a little more readable.)
using system
System error 85 has occurred. The local device name is already in use.
dollar caret E reports The system cannot find the file specif
+ied
dollar Exclamation mark reports
dollar question mark reports 512
using backticks
System error 85 has occurred. The local device name is already in use.
dollar caret E reports The pipe has been ended
dollar Exclamation mark reports
dollar question mark reports 512
What I really want is the english readable message eg
System error 85 has occurred.The local device name is already in use. I think this is coded somehow in $? but my brain hurts and I can't figure it out.
Has anyone any hints, tricks or a suggestion of where I should be looking for the answer?