Question

I login to AS400 and go to QSHELL(STRQSH). After that I pasted the following command and run it in QSHELL

system "IVIEW/PRTDISTL APPNAME(MYJOBLOG) STMF(TEST_89.PDF) HOLD(*NO)"

It works. But when I execute the above command using PHP script as the follow

$cmd = "IVIEW/PRTDISTL APPNAME(MYJOBLOG) STMF(TEST_89.PDF) HOLD(*NO)";
$cmd = 'system "' . $cmd . '"';

$output = array();
exec ($cmd, $output , $retVal);

echo "return value code: " . $retVal;

It returns error code of 255. Please help me how to fix this issue. Thanks

No correct solution

OTHER TIPS

Try the PHP Toolkit for i5/OS. There is a older Redbook that describes it: http://www.redbooks.ibm.com/redbooks/pdfs/sg247327.pdf

An example from there:

<HTML>
<?php
/* Connect to server */
$conn = i5_connect("localhost", "PHPUSER", "MYPASSWORD");
if (!$conn)
die("<br>Connection using \"localhost\" with USERID and PASSWORD failed. Error
number =".i5_errno()." msg=".i5_errormsg())."<br>";
else
echo "<br>Connection using \"localhost\" with USERID and PASSWORD OK!<br>\n";
/* Call Retrieve Network Attributes command */
$ret = i5_command("rtvneta", array(), array("sysname" => "sysn", "lclnetid"=>"lclnet"));
if (!$ret) die("<br>rtvneta command failed. errno=".i5_errno()."
msg=".i5_errormsg());
print "<h1><b>Results of \"rtvneta\" command </b></h1><br>" ;
print "System Name : $sysn<br>" ;
print "Local Net ID : $lclnet<br>" ;
/* Close connection */
i5_close($conn);
?>
</HTML>

I see two pontential problems:

  1. PHP runs in PASE, not in QShell. Try to manually run your call from QP2TERM.
  2. User rights. Make sure QTMHHTTP (or whatever user runs PHP) has the apropriate rights to the program you try to call.

You can check for further information in stdout, which you should have in $output, and your PHP-server joblog as mentioned at IBM i information center (possibly needing the flag 'system -K').

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top