I the code below, I can run $retCode = ClearCase($cmd); with no error, but return 65280 when run this: $retCode = ClearCase($logcmd); I tried on XP and Windows 2003 server, same result, all with ActiveState Perl v5.14.2.
This code was working 2 years ago somewhere else.
Thanks Jirong
$g_HPPC_DEV_DRIVE = "M";
$g_HPPC_DEV_VIEW = "bldforge_AOMS_DEV";
$g_logfile = "logfile.txt";
$cmd = "startview $g_HPPC_DEV_VIEW";
$logcmd = $cmd . " >> $g_logfile 2>>&1";
$targetDir = $g_HPPC_DEV_DRIVE . ":\\" . $g_HPPC_DEV_VIEW;
print "\$targetDir = $targetDir\n";
print "Starting view .......\n";
#$retCode = system("cleartool startview bldforge_AOMS_DEV >> logfile.txt");
#$retCode = `cleartool startview bldforge_AOMS_DEV`;
$retCode = ClearCase($logcmd);
#$retCode = ClearCase($cmd);
sub ClearCase
{
my $retCode = 0;
my $args = $_[0];
my $cmd = "cleartool " . $args;
$retCode = Execute($cmd);
return $retCode;
}
sub Execute
{
my $retCode = 0;
my $cmd = $_[0];
if ($g_HPPC_BUILD_SIMULATION ne "Y")
{
print("Execute() Running...: $cmd\n");
$retCode = system($cmd);
#$retOut = `$cmd`;
#$retCode = $?;
#print("Command execute output: $retOut\n");
}
else
{
print("Execute() *** SIMULATION: $cmd\n");
}
print("Execute() retCode = $retCode, $cmd\n");
return $retCode;
}
Remember that as documented in perldoc -f system, the return value of system
"...is the exit status of the program as returned by the wait call. To get the actual exit value, shift right by eight...". Shifting 65280 by 8 yields 255.
But unfortunately that's not terribly helpful either, because as far as I can determine, the exact meaning of each possible cleartool
exit code is not documented. The closest I can find is this link within the cleartool documentation, wherein it states, "The exit status from single-command mode depends on whether the command succeeded (zero exit status) or generated an error message (nonzero exit status)."
So there you have it; a 255 is a nonzero exit status, which indicates an error condition. On the bright side, maybe it's generating an error message that you're just not seeing.
As a troubleshooting technique, since you're already printing $cmd
, from the command line invoke cleartool
with the same command that your program generated. If you get the same result, the question becomes a cleartool
question rather than a Perl question. And with a little luck that error condition will generate an error message that you can actually see rather than just an exit code.
On the other hand, if you get correct behavior, start looking at what is different between the Perl runtime environment and the command-line environment; permissions, environment variables, paths, working directory, etc.