FTP a file from the IFS

1,380 pts.
Tags:
.CSV files
IFS
iSeries AS/400
I have a .CSV file on the IFS that I want to FTP out to another server(not ours).  I am running the STRTCPFTP command from a clp program.  Input file is overridden to a text file in the same library. 

I try to Put /home/folder/filename.csv

Their server replys with:

File name format not valid.  Use the format: library/file.member or file.member

This makes me think that they are on an iSeries as well.  If that is true, I don't have to use the IFS.

I am looking for suggestions if anyone has any good ones.



Software/Hardware used:
iSeries, FTP, IFS
ASKED: March 6, 2012  11:01 PM
UPDATED: March 17, 2012  1:08 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

I agree, if the server responds with “file format not valid”, you reached an iSeries.
namefmt 1 command in FTP changes from file/library to IFS file structure
Try this in a CL:
PGM
DCL &SYSNAM *CHAR 10 VALUE(’10,1,1,254′)
DCL &CMDFILE *CHAR 10 VALUE(‘FTPCMD ‘)
DCL &LOGFILE *CHAR 10 VALUE(‘FTPLOG ‘)

OVRDBF FILE(INPUT) TOFILE(*LIBL/&CMDFILE) +
OVRSCOPE(*CALLLVL)

OVRDBF FILE(OUTPUT) TOFILE(*LIBL/&LOGFILE) +
OVRSCOPE(*CALLLVL)

FTP RMTSYS(&SYSNAM)

The “FTP” command will read instructions from “INPUT” and write a log of responses to “OUTPUT”
I created files FTPCMD and FTPLOG as normal PF, Record Length 80, not dds defined.
cd – change working directory on target server
lcd – change working directory on source server

Use DFU or a file editor of your choice to add the commands to FTPCMD. Here is a sample command string for iSeries to iSeries FTP to the IFS

USERID password
namefmt 1
lcd /home/
cd /home/
put sample.csv
quit

Have Fun!

Discuss This Question: 9  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    First, connect to the server with an interactive FTP session and try the NAMEFMT 1 command to see if both sides change the naming format. If they do, then the other side is quite probably in the AS/400 line. In any case, you'll need to have NAMEFMT 1 set as your naming format in order to reference a file in your /root file system. Without seeing the rest of your FTP script, I could only guess why it's not switching naming formats automatically. Tom
    125,585 pointsBadges:
    report
  • NickHutcheson1
    Thanks Tom. That is it. The script is: ID password Put /home/folder/filename.csv quit I did find that the name of the file was too big. They want a unique name, so we were trying to use a name like AAABBB with the datestamp from the job attached to the end. I renamed the file to something much shorter, AAABBB.CSV and tried again. Now it says that the file is not found in QGPL. So, with what you just told me and what it just said points me to namefmt 1. It evidently defaults to the library/filename member format when I need it to look at the IFS. So, I need it to look at /Home/sub/AAABBB.CSV (where sub= the subfolder name). Tomorrow, I will try the namefmt 1 and do a cd /home/sub/ before the put statement. I will post afterwards, hopefully with good results. Thanks again. Nick
    1,380 pointsBadges:
    report
  • TomLiotta
    ...and do a cd /home/sub/... Are you wanting to put the file into that directory on the remote site? And is it in the same directory path on your system? You might use lcd /mydir/mysub as the first FTP command, then use cd /theirdir/their/sub as the second FTP subcommand. As the first command to reference a path, the lcd command should cause your session to switch automatically to NAMEFMT 1. And with both lcd and cd already set, your put can simply be Put filename.csv. The two paths can be the same or different. Tom
    125,585 pointsBadges:
    report
  • NickHutcheson1
    ID PSWD namefmt 1 lcd /home/sub put filename.csv quit This worked. On receiving a file from them, it will be basically the same thing, just a different subfolder on their side. I'm on a roll (for the moment). Thanks, Nick
    1,380 pointsBadges:
    report
  • NickHutcheson1
    I need to pick up 4 files. Not sure what the names will be. Will this work? get *.csv
    1,380 pointsBadges:
    report
  • BigKat
    you need to use mget instead of get for wildcards (*.csv)
    7,585 pointsBadges:
    report
  • carlosdl
    Usually, to transfer more than one file you have to use mget (or mput): mget *.csv
    65,110 pointsBadges:
    report
  • NickHutcheson1
    BigKat, Carlos; I am making the change to mget. I am going to keep the two seperate put commands because I am changing the file name with each transmission. Thanks guys. I also wanted to come up with a way to check for errors in the ftp log file. I built a simple querry to run over the file after the transmission and look at the first three positions of the source field. It will look for known error codes (from the FTP manual). 425, 426, 450, 451, 452, 500, 501, 502, 503, 504, 530, 550. These records are listed in a file and sent as an email to the ITDEPT. It should give us a heads up if any of these errors occur. Does anyone know of other error codes in the FTP Log to monitor?
    1,380 pointsBadges:
    report
  • TomLiotta
    It will look for known error codes (from the FTP manual). ... Does anyone know of other error codes in the FTP Log to monitor? Well, that's a problem. First of all, the "messages" in the FTP log are just text strings. Different FTP servers can generate different strings and might use different numeric codes for similar. The messages are sent from the remote server, so you'll never be sure exactly what to expect. Most likely, you'll be okay -- just don't try to guarantee it. The basic format is 3-digits followed by a space or a special character, e.g., "-". The special character is a modifier that usually is just a 'continuation' character. But you have to be careful because one type of message that you get in the log will look like this:
    467 bytes transferred in 2.845 seconds. ...
    What if the transfer had 425, 426 or 450 bytes or any other length that matched one of your error codes instead of '467 bytes'? Other similar problems can show up. If you're really going to do this right, don't use FTP. Use something like Scott Klement's FTPAPI instead. You'll be much better off in the long run. (It might even be easier in the short run.) Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following