Midrange News for the IBM i Community


Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
Log is garbage in my new SFTP CL program
has no ratings.
Published: 02 Aug 2012
Revised: 23 Jan 2013 - 1583 days ago
Last viewed on: 24 May 2017 (3783 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Log is garbage in my new SFTP CL program Published by: Chris Proctor on 02 Aug 2012 view comments(5)

Well, thanks to the IBM manual, and the guys on this site, it appears that I finally have SFTP configured properly; however, I've been trying to write a log within my CL program and it is written to the IFS as garbage. It appears that maybe it's not in ascii, or something like that. I've tried 2 ways, and neither produces a readable log. Here's what I've tried:

 

1) Using verbose to write a debug log (not my preferred log):

CHGVARVAR(&CMD)VALUE('PATH=$PATH:/QOpenSys/usr/bin && sftp -vv -b +

 

/script/firstdata.ftps $SFTP_USER@$SFTP_HOST >

+

 

/script/log/firstdata.txt 2>&1'

)

 

2) Using an environment variable and creating the log with FILEAPPEND:

addenvvar envvar(QIBM_QSH_CMD_OUTPUT) value('FILEAPPEND=/script/log/sftplog.txt') replace(*yes)

 

The second option was in Scott Klement's presentation, and I thought would be the cleanest, but it's not working as I expected.

Is there another parm I need to specify to get it to write out in readable format?

Thanks!

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: BrianR
Premium member *
Green Bay, WI
Comment on: Log is garbage in my new SFTP CL program
Posted: 4 years 9 months 23 days 1 hours ago

The log on my system (using Scott's suggested method) is CCSID 37 (EBCDIC).  If I display it with DSPF STMF('/path/file.txt'), it works OK.  What is the CCSID of the log file and how are you displaying it?

Posted by: chrisp
Premium member *
Portland, OR
Comment on: Log is garbage in my new SFTP CL program
Posted: 4 years 9 months 23 days 13 minutes ago

Hi Brian. I noticed that there is a CCSID parm on the ADDENVVAR command. I'm going to change the value to 37 and see what happens.

Thanks!

Posted by: chrisp
Premium member *
Portland, OR
Comment on: Log is garbage in my new SFTP CL program
Posted: 4 years 9 months 19 days 1 hours 22 minutes ago

Hi Brian

Well, I tried the ADDENVVAR command with the FILEAPPEND and CCSID=37, and the ftplog still is garbage. I'm trying to look at it via iNav.  Any ideas??? I'm assuming it should be viewable text.

Thanks! 

Posted by: BrianR
Premium member *
Green Bay, WI
Comment on: Log is garbage in my new SFTP CL program
Posted: 4 years 9 months 18 days 23 hours 27 minutes ago
Edited: Mon, 06 Aug, 2012 at 17:28:22 (1753 days ago)

Look at the CCSID of the log file (WRKLNK, navigate to the directory the file is in, take option 8=Display attributes on the file).  On my system, the log file is CCSID 37 (EBCDIC), so most PC tools can't read it since they assume it's in ASCII.

To verify that the contents of the log file is actually CCSID 37, take option 5=Display in WRKLNK, press F10, and inspect the hex data.  If you see x'40' for a space, then the file is indeed CCSID 37.

If you need to convert it into ASCII, you could use the COPY command and specify the TOCCSID parameter.

Posted by: chrisp
Premium member *
Portland, OR
Comment on: Log is garbage in my new SFTP CL program
Posted: 4 years 9 months 18 days 4 hours 48 minutes ago
Edited: Tue, 07 Aug, 2012 at 13:30:31 (1752 days ago)

That worked like a champ, Brian! Thanks again!