× 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.



Hi everyone
Before I forget, we are on V5r4
I have to use sftp to obtain files from another server
I have already posted a couple of questions here before, that people have been so kind to answer
Unfourtunately - I am floundering
I googled quite a few things and found this site that does part of what I need to do

http://forums.iprodeveloper.com/forums/aft/55771

titled "How to get results of LS command from SFTP" where someone posted a question that easily could have been me
Scott Klement provided examples of which I used
Here is what I have ended up with

PGM
/* To compile: */
/*> CRTPF QTEMP/LSOUTPUT RCDLEN(1000) <*/

/* FIXME: Replace the following 3 lines with the appropriate +
values for your environment */

DCL VAR(&USERID) TYPE(*CHAR) LEN(15) +
VALUE('j_nbty')
DCL VAR(&HOST) TYPE(*CHAR) LEN(100) +
VALUE('sftp ftpnonprodnbtysldc ')
DCL VAR(&DIR) TYPE(*CHAR) LEN(100) +
VALUE('DNBT2O/incoming/ATG/ESB/RequestCatalog/feed/')
DCL VAR(&SCRIPT) TYPE(*CHAR) LEN(100) +
VALUE('/tmp/sftpscript.txt')
DCL VAR(&CMD) TYPE(*CHAR) LEN(500)
DCL VAR(&EOF) TYPE(*LGL) VALUE('0')
DCL VAR(&NULL) TYPE(*CHAR) VALUE(X'00')
DCLF FILE(LSOUTPUT)

ADDENVVAR ENVVAR(SFTP_USER) VALUE(&USERID) REPLACE(*YES)
ADDENVVAR ENVVAR(SFTP_HOST) VALUE(&HOST) REPLACE(*YES)
ADDENVVAR ENVVAR(SFTP_SCRIPT) VALUE(&SCRIPT) +
REPLACE(*YES)
ADDENVVAR ENVVAR(SFTP_DIR) VALUE(&DIR) REPLACE(*YES)
ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) +
VALUE('FILEAPPEND=/tmp/sftplog.txt') +
REPLACE(*YES)
ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE(Y) +
REPLACE(*YES)

DLTF FILE(QTEMP/LSOUTPUT)
MONMSG MSGID(CPF2105)

CRTPF FILE(QTEMP/LSOUTPUT) RCDLEN(1000)

CHGVAR VAR(&CMD) VALUE('echo "cd $SFTP_DIR\nls" > +
$SFTP_SCRIPT && sftp -b $SFTP_SCRIPT +
$SFTP_USER@$SFTP_HOST | grep -Ev +
"^[.]|^sftp> /qtcptmm/SFTPlogoutput.txt +
2>&1"')

SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(&CMD) +
MSGTYPE(*DIAG)

OVRDBF FILE(STDOUT) TOFILE(QTEMP/LSOUTPUT)
/* CHGVAR VAR(&CMD) VALUE(&CMD *TCAT '> +
/qtcptmm/SFTPlogoutput.txt 2>&1') */
CHGVAR VAR(&CMD) VALUE(&CMD *TCAT &NULL)
CALL PGM(QP2SHELL) PARM('/QOpenSys/usr/bin/sh' +
'-c' &CMD)
DLTOVR FILE(STDOUT)
OVRDBF FILE(LSOUTPUT) TOFILE(QTEMP/LSOUTPUT)

DOUNTIL COND(&EOF *EQ '1')
RCVF
MONMSG MSGID(CPF0864) EXEC(CHGVAR VAR(&EOF) +
VALUE('1'))
IF COND(&EOF *EQ '0') THEN(DO)

/* FIXME: The following line is for debugging purposes only. +
Replace it with one that uses &LSOUTPUT to do some +
work. */

SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) +
MSGDTA(&LSOUTPUT) MSGTYPE(*DIAG)
ENDDO
ENDDO

DLTOVR FILE(LSOUTPUT)

ENDPGM

I have compiled this and run it, but the file QTEMP/LSOUTPUT is empty
I have also run sftp interactively using the following commands
CALL PGM(QP2TERM)
And pressed Enter

On the
/QOpenSys/usr/bin/-sh'
Screen, I typed
sftp ftpnonprodnbtysldc
and pressed Enter

I then typed
cd DNBT2O/incoming/ATG/ESB/RequestCatalog/feed/
and pressed Enter

I then typed
Ls
And pressed Enter
And what was displayed is what I expected to see

The questions are - what is wrong with my CLP program and how can I log what happens within sftp


As always - any and all responses gratefully accepted

Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill


Disclaimer: This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.