× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



The {$a} is resolved by PHP as these are variables that have come from another API that lists the users spool files. This function is really mimicking the WRKSPLF behavior. So, we go out and get a list of spool files for the user, then allow them to view the spool file from the browser.

We will try moving the quotes. At this point I'll try most anything.

Jim Oberholtzer
Chief Technical Architect
Agile Technology Architects

On 6/6/13 1:24 PM, Thorbjørn Ravn Andersen wrote:
Do the single quotes survive to the actual shell command? If yes, consider
just having them like

catsplf -j '{$....}'

so there are a command and two arguments on the command line. Typicall with
quotes as you put them try to invoke a command called 'catsplf -j ....'
(spaces and all). Also, what expands the {$a} syntax?

-----Original Message-----
From:web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On
Behalf Of Jim Oberholtzer
Sent: 5. juni 2013 16:04
To: Web Enabling the IBM i (AS/400 and iSeries)
Subject: Re: [WEB400] Error on QSH call that I can't figure out

Paul,

The command string " 'catsplf -j {$jobNumber} / {$userName} / {$jobName}
{$spoolName} {$spoolNumber}' " is all concatenated together by PHP into a
single string. The command needs the single quotes so the QSH will not try
and interpret the "-j" and the "/" characters individually.

The "\" characters are not needed at all.

One suggestion was to check if the single quotes were needed at all, and
testing reveals they are needed.

Jim Oberholtzer
Chief Technical Architect
Agile Technology Architects

On 6/5/13 8:37 AM, Paul Therrien wrote:
>Jim, I am not certain I understand, so please forgive me.
>Are you including the single quotes around the command string? The example
you showed does not appear to have them:
><snip>
>$cmdString = "catsplf -j {$jobNumber}/{$userName}/{$jobName}
>{$spoolName} {$spoolNumber}";
></snip>
>
>I would think you needed something like this:
>$cmdString = "\'catsplf -j {$jobNumber}/{$userName}/{$jobName}
>{$spoolName} {$spoolNumber}\'";
>
>Paul
>
>-----Original Message-----
>From:web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx]
>On Behalf Of Jim Oberholtzer
>Sent: Wednesday, June 05, 2013 7:53 AM
>To: Web Enabling the IBM i (AS/400 and iSeries)
>Subject: Re: [WEB400] Error on QSH call that I can't figure out
>
>The single quote wind up being needed since the "-j" and the "/"
>characters are part of the command string. Dang I thought you were on to
something.
>
>Jim Oberholtzer
>Chief Technical Architect
>Agile Technology Architects
>
>On 6/4/13 6:16 PM, Jim Oberholtzer wrote:
>> >Excellent question, I'll check that out! That might explain the null
>> >response. The part that has us a bit confused is on the development
>> >box this code works, in the production deployment it does not work.
>> >
>> >I will go back and check the quotes to be sure.
>> >
>> >An earlier suggestion that I check plugsize did not pan out to be
>> >the problem.
>> >
>> >Jim Oberholtzer
>> >Chief Technical Architect
>> >Agile Technology Architects
>> >
>> >On 6/4/13 4:13 PM, Paul Therrien wrote:
>>>> >> >*This message was transferred with a trial version of
>>>> >> >CommuniGate(r)
>>>> >> >Pro* Do the single quotes need to surround the $cmdString?
>>>> >> >It doesn't appear that the $cmdString value has the single quotes
embedded in it.
>>>> >> >
>>>> >> >
>>>> >> >Paul
>>>> >> >
>>>> >> >-----Original Message-----
>>>> >> >From:web400-bounces@xxxxxxxxxxxx >>>> >> >[mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Jim
>>>> >> >Oberholtzer
>>>> >> >Sent: Tuesday, June 04, 2013 2:55 PM
>>>> >> >To: Web Enabling the AS400 / iSeries
>>>> >> >Subject: [WEB400] Error on QSH call that I can't figure out
>>>> >> >
>>>> >> >Folks: In the following code (PHP), we are attempting to pull in a
spool file into the variable $result so we can format it and put it up on a
web page. If we run the command via the PHP code we get a null in $result.
If we run the command ( signed on as the same user ) from the command line
it works.
>>>> >> >
>>>> >> >QSH CMD('catsplf -j 026555/KATTANASIO/H512D QPJOBLOG 2')
>>>> >> >
>>>> >> >I checked to see if the user profile had *SPLCTL and it does.
>>>> >> >
>>>> >> >Any Idea what might be going on?
>>>> >> >
>>>> >> >
>>>> >> >function i5_spool_get_data($spoolName, $jobName, $userName,
$jobNumber, $spoolNumber, $fileName = '', $connection = null) {
>>>> >> > if (!$connection = verifyConnection($connection)) {
>>>> >> > return false;
>>>> >> > }
>>>> >> >
>>>> >> > if (!is_numeric($spoolNumber)) {
>>>> >> > // could be *NEXT or other misguided parameter. Use a
'1' for compatibility.
>>>> >> > $connection->logThis("Spool file number value
'$spoolNumber' is unsupported. Please supply a number. The value '1' will be
used.");
>>>> >> > $spoolNumber = 1;
>>>> >> > }
>>>> >> >
>>>> >> > $cmdString = "catsplf -j
>>>> >> >{$jobNumber}/{$userName}/{$jobName}
>>>> >> >{$spoolName} {$spoolNumber}";
>>>> >> >**********************
>>>> >> >call making the trouble below!
>>>> >> >************************
>>>> >> > //full command will look like "QSH CMD('catsplf -j
{$jobNumber}/{$userName}/{$jobName} {$spoolName} {$spoolNumber}')";
>>>> >> > $result = $connection->qshellCommand($cmdString);
>>>> >> >
>>>> >> > // if no error, we expect an array.
>>>> >> > if (is_array($result)) {
>>>> >> > // consolidate into a string with 0D0A separators
>>>> >> > $resultString = trim(implode("\r\n", $result));
>>>> >> >
>>>> >> > // if fileName provided, try to write data to the IFS
file (return true if successful or false).
>>>> >> > // otherwise simply return the string.
>>>> >> > if ($fileName) {
>>>> >> >
>>>> >> > $bytesWritten = file_put_contents($fileName,
$resultString);
>>>> >> > if ($bytesWritten) {
>>>> >> > // good! Wrote OK
>>>> >> > return true;
>>>> >> > } else {
>>>> >> > // bad! Could not write file. Old toolkit used
CPF9898 so let's also use it.
>>>> >> > i5CpfError('CPF9898', "Could not write to file
'$fileName'.");
>>>> >> > return false;
>>>> >> > } //(if bytesWritten)
>>>> >> >
>>>> >> >
>>>> >> > } else {
>>>> >> > // no IFS filename provided. Return string to
caller.
>>>> >> > return $resultString;
>>>> >> > } //(if $fileName)
>>>> >> >
>>>> >> > } else {
>>>> >> > // not an array. Probably a "false."
>>>> >> > // Report the error.
>>>> >> > $errMsg = $connection->getErrorMsg();
>>>> >> > if (empty($errMsg)) {
>>>> >> > $errMsg = 'Could not read spooled file. Check user
permissions or see error code for details.';
>>>> >> > }
>>>> >> > i5CpfError($connection->getErrorCode(), $errMsg);
>>>> >> > return false;
>>>> >> > } //(if is_array)
>>>> >> >
>>>> >> >
>>>> >> >} //(i5_spool_get_data)
>>>> >> >
>> >--


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.