Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl system() call failed with return code 65280

I run the perl code below.

$retCode = ClearCase($cmd); 

Works with no error, but it returns 65280 when I 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.

  $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;
}

What is the meaning of this 65280 exit code?

like image 452
Alex Avatar asked Jan 15 '23 19:01

Alex


2 Answers

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.

like image 122
DavidO Avatar answered Jan 31 '23 08:01

DavidO


When using cleartool, it is best to ensure using ccperl (now called ratlperl), the perl packaged with ClearCase, instead of the very latest Active Perl (which actually is the 5.14.2).

So instead of launching your perl script by default, picking up the first perl.exe available in your %PATH%, try calling it with one of the perl included with ClearCase:

  • ratlperl: in C:\Program Files\Rational\Common.
  • or the legacy ccperl: in C:\Program Files\Rational\ClearCase\bin.

And see if the error persists.

The root cause was a PATH issue: several perl were available:

  • the ones from Rational ClearCase
  • the one from Active Perl

By making sure the PATH only reference one perl (the one shipped with ClearCase), the script could be launched successfully.

like image 21
VonC Avatar answered Jan 31 '23 07:01

VonC