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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP to AS/400 System 1

Status
Not open for further replies.

jessicatech

Programmer
Oct 24, 2006
19
MY
Hello,

I normally use FTP (IP address) to load file into the AS/400 system. How can I automate the following:

OPEN
FTP 9.9.9.9
User
Password
PUT FILE.MEMBER
BYE

I would like the above file (either batch or script) to prompt for USER and PASSWORD interactively (instead of storing them in the batch/script file).

Please advise and Thank you.
 
This gives you a help
Code:
ftp -h

you will get all switches
Code:
D:\Analyza\Query>ftp -h

Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.

FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [-A] [host]

  -v             Suppresses display of remote server responses.
  -n             Suppresses auto-login upon initial connection.
  -i             Turns off interactive prompting during multiple file
                 transfers.
  -d             Enables debugging.
  -g             Disables filename globbing (see GLOB command).
  -s:filename    Specifies a text file containing FTP commands; the
                 commands will automatically run after FTP starts.
  -a             Use any local interface when binding data connection.
  -A             login as anonymous.
  -w:buffersize  Overrides the default transfer buffer size of 4096.
  host           Specifies the host name or IP address of the remote
                 host to connect to.
so you see, you need the s-Option.
You can also use an script getsavf which contains the ftp commands and then call your ftp on this script using
Code:
ftp -n -s:getsavf
But if you make this so, you will probably have a problem with password. It's not good to store password in clear text in the text files :)
Some years ago I used such a simple download.bat file.

Code:
REM downloading over ftp

echo open csebk01 > getsavf
echo user romanaps %1 >>getsavf
echo lcd d:\query >> getsavf
echo cd RM" >> getsavf
echo bin >> getsavf
echo get qrysavf.savf >> getsavf
echo bye >> getsavf
ftp -n -d -s:getsavf
del getsavf

if you call this bat-file with your password as command line parameter:
Code:
download.bat mysecret
it creates first the command file getsavf for ftp:
Code:
open csebk01 
user romanaps mysecret 
lcd d:\query 
bin 
get qrysavf.savf 
bye
then feeds ftp with it
and finally it deletes the getsavf file (because it contains my password :))
 
Sorry I mistyped myself in the script, it is
Code:
REM downloading over ftp

echo open csebk01 > getsavf
echo user romanaps %1 >>getsavf
echo lcd d:\query >> getsavf
echo cd RM >> getsavf
echo bin >> getsavf
echo get qrysavf.savf >> getsavf
echo bye >> getsavf
ftp -n -d -s:getsavf
del getsavf

and then the generated command file for ftp is
Code:
open csebk01 
user romanaps mysecret 
lcd d:\query 
cd RM 
bin 
get qrysavf.savf 
bye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top