AS400 FTP GET issue

HI,

I have a Model 9406-170 with OS: V4R4M0

I can login to this system via FTP and navigate to the AS400 library (MFG.PMS) that I want to download files from. I have verified through green screen that the files PMCR06.PGM and PMCR06CL.PGM exist in this library.

My FTP "pwd" command output:
257 "MFG.PMS" is current library

My FTP "ascii" command output:
200 Representation type is ASCII nonprint.

My FTP "get PMCR06.PGM" OR "get PMCR06" command output:
550 File PMCR06 in library MFG.PMS not found.  
550 File PMCR06.PGM in library MFG.PMS not found.

So I attempted FTP command "dir" and get this output:
200 PORT subcommand request successful.
126 Member *ALL not found in file *ALL in library MFG.PMS.
250 List Completed.

NOTE: I ultimately want to do the following via FTP...
1) Start FTP session.
2) Set FTP session to ASCII.
3) Set FTP session to not prompt.
4) Navigate to an AS400 library.
5) Download all files in the library via FTP command mget *
Repeat starting at step 4.

I'm new to the AS400 but not FTP.  Anyone have any tips?  

Thanks!
Michael SmithAsked:
Who is Participating?
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:
FTP server on IBM i/iSeries/AS400 can only transfer IFS files (stream files) and QSYS.lib (native file system) *FILE objects.

To move around other native objects using FTP you need to save them to a save file, and transfer the save file.

CRTSAVF, SAVOBJ on sending system, then GET the savf.

If you want to restore them, on the receiving system system you should CRTSAVF,  then PUT to the savf.

Note if you are just trying to transfer system to system, you may be able to use the ObjectConnect command SAVRSTOBJ, if installled, instead of FTP.
Gary PattersonVP Technology / Senior Consultant Commented:
A save file is the AS400 equivalent of a zip file.  It is a container for one or more objects.
Gary PattersonVP Technology / Senior Consultant Commented:
Here is an IBM article on sending save files

https://www-01.ibm.com/support/docview.wss?uid=nas8N1013889
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Michael SmithAuthor Commented:
Thank you and my apologies I should have stated that I'm executing this FTP from my PC.  The object of the steps below is to get all COBOL program files and CL files onto my PC in order to more easily interrogate them (file editor searches) and inventory them (in Excel).    

Is there an easy way to do that (note: in my notes/steps in my first post I was setting my session to ASCII as I believe an EBCIDIC to ASCII translation must be done).

Thanks

NOTE: I ultimately want to do the following steps via FTP...
1) Start FTP session.
2) Set FTP session to ASCII.
3) Set FTP session to not prompt.
4) Navigate to an AS400 library.
5) Download all files in the library via FTP command mget *
Repeat starting at step 4.
Gary PattersonVP Technology / Senior Consultant Commented:
Why do you need to transfer program objects?  Backup?  Migration to another system?  Change management?  Archive?
Gary PattersonVP Technology / Senior Consultant Commented:
*PGM objects are compiled objects.  Not source code.  Useless to you on your PC.  Like transferring a compiled linux executable to a Windoes box.

I assume you want source code.  Whole different conversation
Gary PattersonVP Technology / Senior Consultant Commented:
In v4r4 source code, if you have it, is stored in source physical files.  A source physical file typically contains multiple members, one member per program.  Sort of like a directory with a bunch of text files in it.

CL source is traditionally stored in QCLSRC or QCLLESRC and COBOL in QLBLSRC.

Here is an article from a more current release that lists the common names.

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_71/dbp/rbafosrcibm.htm

Note, however, that a developer can store source code in a file with any name they choose.

Your task can be complex depending on the system.
Michael SmithAuthor Commented:
Thanks!

Short version of a long story... I've been handed an AS400 with a full ERP software package on it written in COBOL.  About a dozen customers.  They need support, etc.  I have an IT background, COBOL experience, etc. trying to help.  My AS400 experience is limited. Currently reading, etc. but one thing I want to do is get this stuff down to my PC so as I said start interrogating, getting an inventory ...crawl, walk run.

I'll start looking for other libraries that have source code.  Still am interested in how to bulk download multiple COBOL source files when I find them.
David Johnson, CD, MVPRetiredCommented:
the source may not be available from the previous developer and only the compiled code is on the machine.
When I ship a program I normally do not include the source code unless paid for or required due to licensing
murugesandinsShell_script Automation /bin/bash /bin/bash.exe /bin/ksh /bin/mksh.exe AIX C C++ CYGWIN_NT HP-UX Linux MINGW32 MINGW64 SunOS Windows_NT started powershellCommented:
@Michael Smith
$# >> *PGM objects are compiled objects.  Not source code.  Useless to you on your PC.  Like transferring a compiled linux executable to a
$# Windoes box.
$# Good comment from Gary Patterson
$ /bin/cat ./Automate_sftp_29110663.sh
#!/bin/ksh
LOCAL_IP=$(/sbin/ip -f inet addr | /bin/grep -w inet | /bin/grep -v "127\.0\.0\.1" | /usr/bin/head -1 | /usr/bin/awk '{ print $2}' | /bin/sed "s/\/.*//;")
LOGNAME=$(/usr/bin/whoami)
if [ ! -d /tmp/murugesandins ]
then
	echo /bin/mkdir /tmp/murugesandins
	/bin/mkdir /tmp/murugesandins
fi
if [ ! -d /tmp/murugesandins/Backup ]
then
	echo /bin/mkdir /tmp/murugesandins/Backup
	/bin/mkdir /tmp/murugesandins/Backup
fi
CURR_PERMISSION=$(/usr/bin/stat /tmp/murugesandins | /bin/grep "Access: (" | /bin/sed "s/Access: (//;s/\/.*//;")
if [ "0777" != "$CURR_PERMISSION" ]
then
	echo /bin/chmod 777 /tmp/murugesandins
	/bin/chmod 777 /tmp/murugesandins
fi
if [ ! -f /tmp/murugesandins.tgz ]
then
	# Better create gz file to reduce ftp transfer timing.
	echo /bin/tar -cvzf /tmp/murugesandins/murugesandins.tgz /tmp/murugesandins
	/bin/tar -cvzf /tmp/murugesandins/murugesandins.tgz /tmp/murugesandins
fi
if [ ! -f /tmp/murugesandins/1.txt ]
then
	echo /bin/cp -ip $0 /tmp/murugesandins/1.txt
	/bin/cp -ip $0 /tmp/murugesandins/1.txt
fi
if [ ! -f /tmp/murugesandins/2.txt ]
then
	echo /bin/cp -ip $0 /tmp/murugesandins/2.txt
	/bin/cp -ip $0 /tmp/murugesandins/2.txt
fi
#This script not written to handle exceptions using $?
SFTP=$(/usr/bin/which sftp 2>/dev/null)
if [ ! -d ~/.ssh ]
then
	echo /bin/mkdir ~/.ssh
	/bin/mkdir ~/.ssh
fi
if [ ! -f ~/.ssh/id_rsa ]
then
	echo /usr/bin/ssh-keygen -N "" -f ~/.ssh/id_rsa
	/usr/bin/ssh-keygen -N "" -f ~/.ssh/id_rsa
fi
CURR_PERMISSION=$(/usr/bin/stat ~/.ssh | /bin/grep "Access: (" | /bin/sed "s/Access: (//;s/\/.*//;")
if [ "0700" != "$CURR_PERMISSION" ]
then
	echo /bin/chmod 700 ~/.ssh
	/bin/chmod 700 ~/.ssh
fi
CURR_PERMISSION=$(/usr/bin/stat ~/.ssh/id_rsa.pub | /bin/grep "Access: (" | /bin/sed "s/Access: (//;s/\/.*//;")
if [ "0600" != "$CURR_PERMISSION" ]
then
	echo /bin/chmod 600 ~/.ssh/id_rsa.pub
	/bin/chmod 600 ~/.ssh/id_rsa.pub
fi
if [ ! -f ~/.ssh/authorized_keys ]
then
	echo /bin/cp -ip ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
	/bin/cp -ip ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
fi
if [ ! -f ~/.ssh/authorized_keys2 ]
then
	echo /bin/cp -ip ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys2
	/bin/cp -ip ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys2
fi
$SFTP $LOGNAME@$LOCAL_IP << GETPMVFILES
cd /tmp/murugesandins/
lcd /tmp/murugesandins/Backup
mget murugesandins.tgz
mget *
quit
GETPMVFILES

Open in new window

Michael SmithAuthor Commented:
Thanks to everyone that replied.  I am in the process of identifying the source and will try to FTP that to my PC.  Will update this string when I do that.
Gary PattersonVP Technology / Senior Consultant Commented:
Use the green-screen DSPPGM command on one of the program objects to help find the source code it was compiled from.

*PGM objects are internally stamped with the location of the source code used at the time of compile: typically contains a system name, a library name, a source file name, and source member name.

Alternatively, you can use the DSPFD command to dump a list of physical files (PF) to an output file, then query that file (or download it to Excel if you don't know how to query it on IBM i) to produce a list of source physical files (there is a column that indicates if a file is a "D"ata file or a "Source" file).  Then you can just inspect the source physical files until you find one that contains members that match your program names.

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
Michael SmithAuthor Commented:
Thanks everyone for the input - very helpful!  I'm good!
Michael SmithAuthor Commented:
Thanks everyone!
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
FTP

From novice to tech pro — start learning today.