Hi,
I have a SFTP process from iSeries to other system. If I run the CL with command sftp -b script.txt
user@server in on-line mode I get the log of process, like:
Connecting to Server... sftp> chdir /home/xxxxxx/copyfile sftp> put testsftp01 Uploading testsftp01 to /home/xxxxxx/copyfie/testsftp01
But if I run in batch mode , in SBMJOB inside a CL I can't see the log I only know if everything was fine or bad, by use of RCVMSG command.
I would like to get this log, if the job was bad.
Could you please give me a hand?
Thanks,
Ricardo
Software/Hardware used:
ASKED:
May 6, 2010 3:14 PM
UPDATED:
May 25, 2010 4:16 PM
I handled this slightly differently, I wanted to keep 10 days worth of logs on the system.
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)
DCL VAR(&CMDOUTPUT) TYPE(*CHAR) LEN(100)
DCL VAR(&CNT#) TYPE(*DEC) LEN(4 0)
DCL VAR(&CNTR) TYPE(*CHAR) LEN(4)
DCL VAR(&LOGDLT) TYPE(*CHAR) LEN(50)
DCL VAR(&LOGNAM) TYPE(*CHAR) LEN(50)
DCL VAR(&MSG) TYPE(*CHAR) LEN(100)
DCL VAR(&TOUSR) TYPE(*CHAR) LEN(10)
RTVJOBA USER(&TOUSR)
/* Start the SSHSBS SubSystem, this will start the sshd daemon */
STRSBS SBSD(SSHSBS)
MONMSG MSGID(CPF1010) /* Subsystem active */
DLYJOB DLY(60)
/* Set the environment variables */
/* Build the command string */
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′)
* Manage Log Files */
/* Manage Log Files */
/* Keep 10 days worth */
/* These can be found in the IFS */
/* in the /tmp Directory */
RTVDTAARA DTAARA(SFTPLOGCNT) RTNVAR(&CNT#)
CHGVAR VAR(&CNT#) VALUE(&CNT# + 1)
CHGVAR VAR(&CNTR) VALUE(&CNT#)
CHGVAR VAR(&LOGNAM) VALUE(&SCRIPT *TCAT ‘log’ *CAT +
&CNTR *CAT ‘.txt’)
CHGDTAARA DTAARA(SFTPLOGCNT) VALUE(&CNT#)
CHGVAR VAR(&CMDOUTPUT) VALUE(‘FILEAPPEND=’ *CAT +
&LOGNAM)
CHGVAR VAR(&CNT#) VALUE(&CNT# – 10)
CHGVAR VAR(&CNTR) VALUE(&CNT#)
CHGVAR VAR(&LOGDLT) VALUE(&SCRIPT *TCAT ‘log’ *CAT +
&CNTR *CAT ‘.txt’)
RMVLNK OBJLNK(&LOGDLT)
MONMSG MSGID(CPFA0A9) /* Object not found */
ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) +
VALUE(&CMDOUTPUT) REPLACE(*YES)
ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE(Y) +
REPLACE(*YES)
* Execute the Qshell command */
QSH CMD(&CMD)
MONMSG MSGID(QSH0000) EXEC(DO)
CHGVAR VAR(&MSG) VALUE(‘File transfer failed! See’ +
*BCAT &LOGNAM)
SNDMSG MSG(&MSG) TOUSR(&TOUSR)
ENDDO
/* End the SSHSBS SubSystem, this will end the sshd daemon */
ENDSBS SBS(SSHSBS)
MONMSG MSGID(CPF1054) /* No subsystem active */
ENDIT: ENDPGM
I now can go back 10 occurences in my SFTP logs.
Hope this Helps,
Bill Poulin