|
I'm using sftp in batch mode, i.e. `sftp -b batchfile user@host`
The batchfile has:
cd directorycontainingfiles
get *
rm *has
I vaguely recall seeing something recently on the list about doing an ls and getting results in a file (or possibly stmf). I actually recall seeing a lot of similar things, but I haven't been good at locating them. That's what happens when the project comes up after someone else has already resolved their issue. :)
--
Sean Porterfield
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Gary Thompson
Sent: Thursday, August 16, 2012 14:49
To: Midrange Systems Technical Discussion
Subject: RE: sftp error in batch when no files to transfer
Sean,
Maybe do a list or dir command before the download?
--Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Porterfield, Sean
Sent: Thursday, August 16, 2012 12:19 PM
To: Midrange Systems Technical Discussion
Subject: sftp error in batch when no files to transfer
This may end up being an RPG question, but it starts with sftp in PASE. I have a scheduled download that runs a shell script which is just a batch sftp retrieve and delete. I put in a check in case there is an error (host not found, bad login, etc.) but apparently the shell script ends in error if there are no files to retrieve. In its current state, my program ends due to the error. Ordinarily, that's probably not a big deal. If, however, I have files that have been downloaded but not processed, they cannot get processed because the program ends after the sftp shell script.
If Qp2RunPase( SHELL_PGM
: *NULL
: *NULL
: 0
: 819
: argv
: envp ) <> 0;
// Error on sftp command
EscErrno(errno);
Else;
// Process files
endif;
This manifests as the following in my joblog:
>From procedure . . . . . . : ESCERRNO
Statement . . . . . . . . . : 3042100
Message . . . . : Text not available for message CPE0000 file QCPFMSG.
Recovery . . . : Add the message description (ADDMSGD) to the message file.
If this is an inquiry message and you need to reply to it, attempt to enter
a valid reply (if you know what it is for this message ID). Otherwise, enter
*N for the system default, or delete the message and the system default will
be sent.
It's not much of a useful error message. It's exactly the same if the error is "Permission denied (publickey,password)."
Is there a way to get a more meaningful error that I can then check in the program? It might be that expect is the answer, though I am not well versed in it. Either that or just ignore the error and hope for the best, but that doesn't sound great either.
--
Sean Porterfield
This email is confidential, intended only for the named recipient(s) above and may contain information that is privileged. If you have received this message in error or are not the named recipient(s), please notify the sender immediately and delete this email message from your computer as any and all unauthorized distribution or use of this message is strictly prohibited. Thank you.
As an Amazon Associate we earn from qualifying purchases.
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.