iSeries Bath SFTP CL Program Problem

I'm trying to help my co-worker resolve the following issue: We have a CL Program that generates a batch input file containing SFTP commands. The process works fine for our HQ iSeries; however, we have 21 independently operated iSeries where the SFTP commands appear as EBCDIC encoded characters: Ã @  ¢`  £¢¢` ¥`â     Æ     aÄæaãÖmÄÄâ%`

IBM suggests that the input file must be created using an ACSII text editor, but that's not possible in this case because the CL Program creates the input file on-the-fly. See IBM Reference:

Is there setting that we can check on the iSeires or a command line parameter that can be added to the CL program?

Our CL Program basically runs a shell script that echos out the commands that creates the SFTP batch input file. See sample:
echo Cd abc-dir-$1-SharedFolder/DIR/PATH > /QOpenSys/download/sftpbatch.txt
echo -rm $2.mbr >>  /QOpenSys/download/dwbatch.txt
echo put /qsys.lib/somelib.lib/$2.file/$2.mbr >>  /QOpenSys/download/sftpbatch.txt
echo quit >>  /QOpenSys/download/sftpbatch.txt

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gary PattersonVP Technology / Senior Consultant Commented:
This is almost certainly a CCSID issue.  It often happens when the CCSID of the stream file doesn't match the encoding.  For example if you create a stream file with the CCSID attibute of 37 (EBCDIC), but put CCSID 815 (ASCII) data in the file.

QSH is very friendly - it tries to dynamically convert CCSIDs for you.  If you mislead it about the CCSID of a file, it will do ugly things like this.

Look at the attributes of the file that you are creating.  What is the CCSID that shows?

Then look at the data in the file using EDTF, for example.  IF you have a bad CCSID on the file, EDTF will typically throw a message when you open the file.  

Also, what is the QCCSID system value on the HQ box vs one of the remote systems?
LajuanTaylorAuthor Commented:
Thank You Gary.

Please see the attached screen shot. Could this be our issue?
Gary PattersonVP Technology / Senior Consultant Commented:

If you're using qshell, you can use "touch" command to create an IFS file with a specific CCSID:

touch -C 1252 /QOpenSys/download/dwbatch.txt

PASE touch command (AIX version) doesn't support the -C option.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Gary PattersonVP Technology / Senior Consultant Commented:
In general, when PASE creates a stream file, it defaults to ASCII (CCSID 819 on a US localized machine).  Most PASE utilities assume everything is ASCII and do not perform automatic CCSID conversion.

Qshell defaults to the CCSID associated with the job.  Unlike PASE, Qshell is CCSID-aware and Qshell utilities typically perform automatic CCSID conversion.

In general, use qshell when calling back and forth from CL - that way you get the benefit of automatic CCSID conversion.
LajuanTaylorAuthor Commented:
Thank You Gary.

We solved the problem by using the touch command in our CL Program that we use to create the input file. We confirmed that the CCSID was 1252 and that the SFTP commands were written to input file correctly.


Gary PattersonVP Technology / Senior Consultant Commented:
Happy to help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.