Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automated FTP from as400 to internal lan ftp server?

Status
Not open for further replies.

PMSLIC

IS-IT--Management
Mar 7, 2002
46
US
I'm trying to automate an ftp session where I'm sending a file from the as400 to an ftp server located on our lan.

I use the following to run a script:
PGM
OVRDBF FILE(INPUT) TOFILE(WTJ932/COIFILE) +
MBR(COIMBR1)
OVRDBF FILE(OUTPUT) TOFILE(WTJ932/COIFILE) +
MBR(COIMBR1)
FTP RMTSYS('10.4.1.14')
DLTOVR FILE(INPUT)
DLTOVR FILE(OUTPUT)
ENDPGM

For the script I use:
<blank line>
user wtj932 summer03a
ascii
cd c:/
lcd wtj932.lib
mput inforce.file
quit

When I run it I get the following:
Output redirected to a file.
Input read from specified override file.
Connecting to remote host 10.4.1.14 using port 21.
220- PMSLIC FTP Server WAR-FTPD 1.65 Ready
220 Please enter your user name.
Enter login ID (wtj932):
331 User name okay, Need password.
Please log in before issuing this command.
Enter an FTP subcommand.
> user wtj932 *********
530 Already logged in. New useraccount denied.
Enter an FTP subcommand.
> ascii
550 Please log in before issuing this command.
Enter an FTP subcommand.
> cd c:/
You must first issue the USER subcommand.
Enter an FTP subcommand.
> lcd wtj932.lib
Could not access library WTJ932.LIB.
Enter an FTP subcommand.
> mput inforce.file
You must first issue the USER subcommand
Enter an FTP subcommand.
> quit
221 Goodbye. Control connection closed.

I am completely confused about the user ID and Password. I've tried using and FTP user ID and Password, a LAN user ID and Password and an AS400 user ID and password but they all com up the same.

I'd like to start there and once thats done move on to the next issue.
 
Take out the blank line at the beginning of the script, and remove the word &quot;user&quot; from the second line. The script as written was assuming that the user was wjt932 (because that's the AS/400 profile and that blank first sent a CR to the system causing the AS/400 to send the AS/400's profile as the profile on the server), but it thought the password &quot;user&quot;.

Also, shouldn't you be using a backslash (&quot;c:\&quot;) intead of a forward slash (&quot;c:/&quot;)?

The script should read:

[tt]<...beginning of script...>
wtj932 summer03a
ascii
cd c:\
lcd wtj932.lib
mput inforce.file
quit
<...end of script...>


&quot;When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return.&quot;

--Leonardo da Vinci

 
Also, you might need to add the line

[tt]namefmt 1[/tt]

before your mput subcommand (if your AS/400 doesn't have that set as a default).


&quot;When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return.&quot;

--Leonardo da Vinci

 
This is what I have come up with and works:

0001.00 coldfusion webstuff
0002.00 del inforce.txt
0003.00 mput wtj932/inforce
0004.00 ren inforce.coi inforce.txt
0005.00 quit

I added the delete because it wouldn't let me rename if an old one was there.
I got an error when I did the namefmt.
Took the ascii out because thats the default
Thanks for you help.
 
What was the error you got with namefmt?


&quot;When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return.&quot;

--Leonardo da Vinci

 
Here is the log:
0016.00 Enter an FTP subcommand.
0017.00 > namefmt 1
0018.00 500 Syntax error, Command not recognized.
0019.00 Client NAMEFMT is 1.
0020.00 Enter an FTP subcommand.
0021.00 > mput wtj932/inforce
0022.00 Unknown extension in database file name.
0023.00 Error processing MPUT parameter wtj932/inforce.
0024.00 Enter an FTP subcommand.
0025.00 > ren inforce.coi inforce.txt
0026.00 501 Permission denied.
0027.00 Enter an FTP subcommand.
0028.00 > quit
0029.00 221 Goodbye. Control connection closed.
 
iSeriesCodePoet:

I always found that having the user id and password on the first line of the script works. PMSLIC's respnse indicated that the namefmt FTP subcommand gave him an error, and I wanted to know what that was.




&quot;When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return.&quot;

--Leonardo da Vinci

 
PMSLIC:

Although [tt]namefmt 1[/tt] is giving an error, it looks like you can live without it.


&quot;When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return.&quot;

--Leonardo da Vinci

 
flapeyre:
If I didn't want a job log could I just omit the following line? Or must it be there?

OVRDBF FILE(OUTPUT) TOFILE(WTJ932/COIFILE) +
MBR(COIOUT)
 
You can omit the override to OUTPUT, if you want. But I think it's a good idea to have an FTP log, in case the job blows up, you can then see what went wrong.

I wrote a program in RPG 4 that reads the FTP log and pages our on-call programmer if there was a problem. The job will end normally whether the FTP transfer completed without an error or not; so it's a good idea to make sure the files actually were transferred, or else you could be in for a nasty surprise later.

If you are interested in the code for that please e-mail me at flapeyre@spamcop.net. You will have to modify it for whatever paging utility you use.


&quot;When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return.&quot;

--Leonardo da Vinci

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top