Return to the FTP Tips
Batch File Transfer via FTP
http://www.as400network.com/nwn/story.cfm?ID=7719
Q. I'm trying to automate the transfer of a PC .txt file to our AS/400 and then automatically trigger a conversion program to
integrate the data into our data files. I wrote a .bat file that uses Rumba AS/400 file transfer to upload the file to the AS/400. I now
must call a CL program from within the .bat file. Can I do this and, if so, how?
A. Although you can't do this with Rumba's file transfer, you can easily do it with FTP. Although FTP's primary function is to perform
file transfers, you can use its RCMD subcommand to execute commands and programs on the AS/400. RCMD is handy for launching AS/400 jobs
that process the transferred files. The following sample FTP command line shows how you can execute under Windows NT a batch FTP job that
performs a file transfer and calls an AS/400 program.
ftp -n -i -s:ftp400cmd.txt S101AA0AThe ftp command starts the Windows FTP application, and the -n and -i switches indicate that the program will run in batch mode and won't perform any interactive prompting. At the end of the line, S101AA0A specifies the name of the AS/400 host system. The -s: switch specifies a file that contains the FTP subcommands to be executed.
The contents of the ftp400cmd.txt file are as follows:
USER myID myPWD cd QGPL put myfile.txt quote rcmd call pgm(mylib/mypgm) quitThe first line supplies the user ID used to connect to the AS/400, and the second line supplies the password. Note that by default these values are sent across the network in clear text. Although this is probably fine for most internal networks, you shouldn't do this for public Internet access. The cd subcommand changes the AS/400's current library to QGPL. The put subcommand sends the file myfile.txt from the Windows NT system to the AS/400's QGPL library. Next, the quote rcmd subcommands execute AS/400 program mypgm in mylib. Finally, the quit subcommand terminates the FTP session. -- Michael Otey, NEWS/400 Senior Technical Editor
[report a broken link by clicking here]