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.
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!
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?
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!
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!
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.