Yes. You are thinking that an error in the command being run in QSH percolates up to RPG. The call to QCMDEXC completed normally. The call to SCP did not. You need to retrieve that value. The QSH command returns with message completion message QSH0005. That won't trigger your On-Error. The second level text will show you if you have an error or not. Run your command interactively, and then prompt the results. You should see something like Command ended normally with exit status 1.

QSH CMD(pwd)
Command ended normally with exit status 0.
QSH CMD('cd /fred')
Command ended normally with exit status 1.

Kevin Bucknum
Senior Programmer Analyst
Tel: 985-893-2550

-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Don Brown
Sent: Friday, September 04, 2015 3:18 AM
To: Midrange Systems Technical Discussion
Subject: Re: Verbose logging when using scp

Thanks Scott - Here is the way the download is being executed;

Could the problem be that I am using QCMDEXC to execute the QSH command ?

D SDSWS 244 253
D SDSUSR 254 263


cmdlen = %len(%trim(CMD));
callp QcmdExc(cmd:cmdlen);

-i /home/sftpuser/.ssh/id_rsa

cmdlen = %len(%trim(CMD));
callp QcmdExc(cmd:cmdlen);
// Handle error here Check SDSMSGID and SDSMSGDTA

Running this code in debug the call completes and the next statement is the endmon. The file being retrieved does not exist but no error is encountered.

Thank you for your assistance.

Don Brown

MSD Information Technology

Suite 5/29 McDougall Street Milton Q 4064 ( 07 3368 7888
+ PO Box 1629 MILTON Q 4054
Ê 07 3368 7877
* Don.Brown@xxxxxxxxxx
È 0408 751 644

I am a proud supporter of THE REFERRAL NETWORK and recommend the services of the other member businesses. For more information please checkout the website

From: Scott Klement <midrange-l@xxxxxxxxxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 03/09/2015 05:30 PM
Subject: Re: Verbose logging when using scp
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>

The exit status should be used to determine if the transfer was
successful. When the exit status reports that something failed, the
error messages (which you call a "log") should be used to determine what
the specific problem was.

I have never found the -v (or -vv or -vvv) to be helpful. These are
really intended for the people who write the code inside the scp (or
other ssh tools) to understand internal processes... not helpful to
people like you or I. That's been my experience, anyway.

We need to understand why you aren't getting a non-zero exit status when
the transfer fails. Can you please explain how you are calling this?
You previously showed some RPG code using QCMDEXC API to run the QSH
command, but it did not show how you retrieved the exit status.

On 9/3/2015 1:41 AM, Don Brown wrote:
I have changed the command as suggested and while I am now getting a log
am not getting the desired information.

Using the following command;
scp '-i /home/sftpuser/.ssh/id_rsa'
'/home/sftpuser/CCL-T-20150902.csv' >
/home/sftpuser/poslogn1.txt 2>&1

Provides this output.
************Beginning of data**************
Warning: Identity file /home/sftpuser/.ssh/id_rsa not accessible: No
file or directory.
************End of Data********************

And the file is successfully received.

I can use -v or -vv or -vvv and the verbosity of the log increases with
each level.

What I want to achieve is to know;

Was the file retrieved successfully
If not -
a) Does the file to be retrieved exist ?
b) Was there a communication or authentication error
c) Something else

Even with verbose logging there is no error as such in the log if I use
file name that does not exist

The following line is received if the transfer is successful
Sink: C0755 389 CCL-T-20150902.csv

The exit status is always 0 regardless if the file is found and
transferred, or the file is not found or if the communication connection

There can be times when the file to be retrieved does not exist and this
can be quite valid but at this stage I am unable to confirm this in any
logging I have been able to obtain from the process.

Does anyone have any suggestions ?


Don Brown

From: Justin Dearing <zippy1981@xxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 02/09/2015 05:09 AM
Subject: Re: Verbose logging when using scp
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>

From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of
Don Brown
I have read I am now more confused if I should be using SCP or SFTP.
I am using SCP as there is only a single file to be transferred at a
time and therefore saw no need to create a script file

scp and sftp are equally secure. The sftp client is intended for
interactive use. scp is better for your purposes. See this supersuer

You probably want to add -C to compress the stream and speed things up.
Having the remote user zip the csv and you unzipping it would reduce the
payload further.

Kevin is correct that -v is as verbose as scp and sftp both get. You
need to pipe the output to a file. However, -v is probably more verbose
than you want, and you probable want to omit it unless you care about
intricacies of the ssh session. Omitting the -v will get you file not
and public/private key wrong error messages.

However, some of those error messages will go to stderr and not stdout
Probably want to use &> instead of > . That will definitely work with
in PASE, I'm not sure about the default ksh shell.

This page is good reading on I/O redirection in unix


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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

This mailing list archive is Copyright 1997-2022 by 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.