Hi all !
this works -
SBMJOB CMD(QSH CMD('/QOpenSys/usr/bin/sftp -v -b +                      /home/account/sftpcmd.txt +                             remote_user_account'))             +                                  JOB(SSHJOB) USER(WIRM5501)
this does not
SBMJOB CMD(QSH CMD( &CMDSHL ))Â Â JOB(SSHJOB) USER(WIRM5501)
where &CMDSHL is the exact quoted command in the working script
I get this error
qsh: 001-0014 Command /QOpenSys/usr/bin/sftp -v -b /home/... not found
I've set these
QIBM_USE_DESCRIPTOR_STDIO and QIBM_QSH_CMD_ESCAPE_MSG
Â
anyone ever made this work, or know why it's failing?
Â
thanks,
Michael
Software/Hardware used:
iSeries as400
ASKED:
March 26, 2012 4:13 PM
UPDATED:
March 30, 2012 11:42 PM
I used triple single quotes at each end to build the variable, and when in debug I see the single quotes in the variable contents
Michael
When you are in debug, have you tried to do a cut & paste.
doin the the past on a command line to see if you get more detail info on the error?
…where &CMDSHL is the exact quoted command in the working script
If it really was the “exact quoted command”, I would expect it to fail. But I also exact that it’s not “exact”. For example, you probably shouldn’t have “+” signs in there.
That is, it’s almost certain that you aren’t showing us what’s actually in &CMDSHL. Instead, you’re describing it to us. It’s practically guaranteed that there is a difference that isn’t being shown.
If you can use debug to see the value, copy/paste from the debug session into Notepad. Then copy/paste from Notepad into a {code} block back here.
By going through Notepad, you’ll be able to capture CR/LFs that don’t exist when you copy from a workstation screen. When you post in a {code} block, the result won’t get the usual compression of blanks that HTML gives. We’ll see more or less exactly what you see.
Tom
Hi again –
the CL command is
CHGVAR &CMDSHL (”’/QOpenSys/usr/bin/sftp -v -b +
/home/WIRM123/sftpcmd.txt wirm123@sftp2.123”’)
using three single quotes
the string from the debug session is as below ( 200 type character string )
‘/QOpenSys/usr/bin/sftp -v -b /home/WIRM123/sftpcmd.txt wirm123@sftp2.123‘
the CL code to execute ( and fails) is
SBMJOB CMD(QSH CMD( &CMDSHL )) JOB(SSHJOB) USER(WIRM123)
the sftpcmd.txt is is a simple text file
cd Share/5501/test/5501updt
ls
put MGG1.TXT MGG1.TXT
ls
exit
this all works when I make the hardcoded call as below
SBMJOB CMD(QSH CMD(‘/QOpenSys/usr/bin/sftp -v -b +
/home/WIRM123/sftpcmd.txt +
wirm123@sftp2.123‘)) +
JOB(SSHJOB) USER(WIRM5501)
but I want to be able to provide different directories and such as this is in a generic CL
intersting problem – but I’ve reached the end of my skills as far as what to be able to test.
…using three single quotes…
Why would you put three quotes there? I’ve never tested it, but what happens when you put quotes around a command on a QSH command line?
If I try this:
…to list my /home directory in a QSH session, I get this error:
QSH thinks that the entire quoted string is the name of the command.
Your &CMDSHL value should probably only have single quotes.
Tom
This can work, I have a similar job that runs thru the Job Scheduler,
Here is a snippet of the code, maybe an example will help,
ZFTP is a command that executes a CL by the same name;
ZSFTP HOST(***.nh.gov) SCRIPT(‘/tmp/lowmo’) +
USER(‘******’)
PGM PARM(&HOST &SCRIPT &USER)
DCL VAR(&HOST) TYPE(*CHAR) LEN(15)
DCL VAR(&SCRIPT) TYPE(*CHAR) LEN(15)
DCL VAR(&USER) TYPE(*CHAR) LEN(15)
DCL VAR(&CMD) TYPE(*CHAR) LEN(500)
ADDENVVAR ENVVAR(SFTP_USER) VALUE(&USER) REPLACE(*YES)
ADDENVVAR ENVVAR(SFTP_HOST) VALUE(&HOST) REPLACE(*YES)
CHGVAR VAR(&CMD) +
VALUE(‘PATH=$PATH:/QOpenSys/usr/bin && +
sftp -b’ *BCAT &SCRIPT *TCAT ‘.sftp +
$SFTP_USER@$SFTP_HOST 22′)
QSH CMD(&CMD)
Again this is run in batch thru the Job Scheduler. There is more code, but I didn’t think it related to executing QSH in batch and with a variable.
Hope this helps,
Bill Poulin
It should be ZSFTP is the command.
Bill
…I didn’t think it related to executing QSH in batch and with a variable.
It’s definitely related when extra quotes are added that shouldn’t be there.
But the idea of using a literal or a variable is sound. Just don’t put quotes in the variable that aren’t present in the literal.
Tom
You probably need to trim the string, and append a X’00′ to the end. This command expects a null terminated parameter
This command expects a null terminated parameter
It’s already known that a null-terminator is not needed. The QSH command works fine without one as demonstrated by the OP’s working example. The issue is in the difference between using a literal for the QSH command parameter and a variable. Because QSH is a system command, it has no need for a null-terminator.
Tom
Tom,
You took my statement out of context. My full statement was;
There is more code, but I didn’t think it related to executing QSH in batch and with a variable.
Thank You,
Bill Poulin
There is more code, but…
Ah. Not exactly out of context, just misinterpreted by me. Now I see the alternative interpretation. In that case, there’s no need for my related comment.
Tom