Link to home
Start Free TrialLog in
Avatar of Michael Smith
Michael Smith

asked on

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!
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
Flag of United States of America image

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.
A save file is the AS400 equivalent of a zip file.  It is a container for one or more objects.
Avatar of Michael Smith
Michael Smith

ASKER

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.
Why do you need to transfer program objects?  Backup?  Migration to another system?  Change management?  Archive?
*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
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.
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.
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
@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

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.
ASKER CERTIFIED SOLUTION
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks everyone for the input - very helpful!  I'm good!
Thanks everyone!