Hello everyone, what does 255 mean from exec()'s return variable?
From PHP Manual
string exec ( string command [, array output [, int return_var]])
exec() executes the given command, however it does not output anything. It simply returns the last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.
I don’t think you understood my question (or i don’t understand the manual). The [, int return_var] returns 255 (return status of the Unix command).
The [, array output [ is returned from the executable file. The file is a verisign file for Payflow Pro, the array output is telling me it failed to connect to Verisign’s server. I want to know if the return_var has any insight as to why. I’m pretty sure each return_var (0-255) represents an error, but I don’t know what errors.
bump
anyone have an idea what the 255 means?
Show me the part of the code you’re using exec() on.
Well, it seems funny to me that 255 is also the limit on a varchar in an sql table.
2c
I found some code on php.net someone posted in the pfpro function: (http://us3.php.net/pfpro)
<?php
// This script shows:
// a) how to use the Payflow Pro commandline binary to process
// a transaction via PHP's system call, and
// b) the setup necessary to make sure that it will work
// Adjust these for your actual login parameters
$user = "MyUserName";
$vendor = "MyUserName"; // also tried vendor ID number
$partner = "VeriSign"; // also tried Verisign (small S)
$pwd = "myPassword";
$host = "test-payflow.verisign.com";
$port = "443";
// Adjust these next two paths appropriately; i.e. where did
// you actually put these two files?
$binary = 'vs_inc/pfpro'; // i also used full paths for includes
$library = 'vs_inc/libpfpro.so';
$newld = dirname($library);
// this is necessary to prevent RESULT=-31 errors; make sure
// it's a *directory* that contains the cert file that came
// with the SDK, and *don't* put a trailing slash on it
putenv("vs_inc");
// This next chunk of stuff assumes you're having linker issues, and
// attempts to fix or work around them.
// Now, let's fix the linker path:
// $original_ld_path = getenv("LD_LIBRARY_PATH");
//$newld .= ":$original_path";
//putenv("LD_LIBRARY_PATH=$newld");
// having set the linker to find the library, now call the binary:
$cmd = "\\"TRXTYPE=S&TENDER=C&PWD=$pwd&USER=$user&VENDOR=$vendor";
$cmd .= "&PARTNER=$partner&ACCT=4222222222222&EXPDATE=1209&AMT=14.42";
$cmd .= "&INVNUM=1234567890&STREET=5199 JOHNSON&ZIP=94588\\"";
$result = exec("$binary $host $port $cmd", $result_array, $exit_value);
$valArray = explode('&', $result);
foreach($valArray as $val) {
$valArray2 = explode('=', $val);
$pfpro[$valArray2[0]] = $valArray2[1];
}
// To look at the array structure
print_r($pfpro);
// This should be equal to the RESULT that came back. If you
// get no result string back, but the exit_value here is 126 or 127,
// you've got linker or permission problems.
echo "the exit value of the system call to pfpro was $exit_value";
?>
The exit value is always 255.
Edit: Also, I tried it using the part of code that is commented out.
If you mean the binary, I don’t know how to open it w/o ruining the source. It’s from Verisign’s Payflow Pro SDK.