4

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?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Alex
  • 180
  • 2
  • 3
  • 10
  • You should `use autodie` or check `$!` to see if you get anything more descriptive. Probably, though, "clearcase" is broken for some reason and you'll need to start your investigation with that rather than your Perl code. – zostay Aug 16 '12 at 14:55
  • That must be [`use autodie qw(:all)`](http://stackoverflow.com/a/3478060) in order to also fatalise `system`. – daxim Aug 16 '12 at 15:24
  • The redirection operator `2>>&1` looks weird, try with a single wedge `2>&1`? – tripleee Aug 16 '12 at 18:12
  • Same with 2>&1. This code was all working in another environment. Don't know why it's not working here. – Alex Aug 16 '12 at 19:04
  • exit code 65280 is an invalid unix exit code number. correct range is 7 bits: 0-255. I receive 65280 exit code from the bash 5.0.18 shell invoking python 3.8.5 on Linux to run an `exit_code = os.system("ssh user@host_ip 'some_command.sh'"` such that some_command takes more than 5 minutes and I force stop sshd server side, unplug the computer, unplug the wireless router or some other swift demise of TCP. Python client side receives no data from the OS, python crams an 64 bit integer into 7 bits: 65280. The number is suspiciously close to max 16 bit value 65,536. – Eric Leschinski Aug 01 '21 at 00:48

2 Answers2

6

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.

DavidO
  • 13,812
  • 3
  • 38
  • 66
  • The problem is still the same: I can run $retCode = ClearCase($cmd); with no error, but return 65280 when run this: $retCode = ClearCase($logcmd); This " >> $g_logfile 2>>&1" is causing the problem. I can run from windows command line with no issue as well. I counldn't get any error message using either system() or `` call. Don't know where it fails. – Alex Aug 16 '12 at 19:14
  • @Alex 65280 is your interpreter programming language stuffing a default 16 or 64 bit number into a 7 bit unix number, this corrupted memory is regurgitated to you by your terminal as 65280. It's a failed fatal error recovery attempt from whatever program producing that number. – Eric Leschinski Aug 01 '21 at 01:00
3

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I am getting this error when using ccperl or ratlperl. There is registry code inside, how to update the version? Win32::Registry object version 0.07 does not match $Win32::Registry::VERSION 0.10 at C:/Program File s/IBM/RationalSDLC/common/lib/perl5/5.8.6/MSWin32-x86-multi-thread/DynaLoader.pm line 253. Compilation failed in require at Z://../common.pl line 12. BEGIN failed--compilation aborted at Z://../common.pl line 12. Compilation failed in require at build.pl line 28. – Alex Aug 16 '12 at 19:01
  • @user1288329 http://www-01.ibm.com/support/docview.wss?uid=swg21289331: "The problem may be caused when there are multiple versions of Perl installed on the same system where the search path environment variable is setup so that the "incorrect" Perl version is chosen first". Make sure your `PATH` doesn't include any other perl – VonC Aug 16 '12 at 19:15
  • @user1288329 retry with a clean PATH (see previous comment), and without your "fix". – VonC Aug 16 '12 at 19:16
  • Remove multiple Perl path resolved the problem. Thank you very much! – Alex Aug 16 '12 at 19:19
  • I have more problems, this time chdir() doesn't work. I've used this code everywhere in ClearCase triggers in this same company. See source code and output below. – Alex Aug 16 '12 at 21:26
  • @user1288329 your "answer" is actually another question. Let's close that first one (I have edited my answer to highlight the PATH issue), and let's tackle the one issue in its own question. – VonC Aug 16 '12 at 21:40
  • OK, it's posted here. http://stackoverflow.com/questions/12006798/perl-chdir-doesnt-work\ And I accepted the answer. This is the first time I post questions here. Looks like this place can post any type of questions? – Alex Aug 17 '12 at 13:32
  • @user1288329 Excellent. I have posted an answer there. – VonC Aug 17 '12 at 13:43