Have you ever using FTP in Windows? Commands are almost similar with Unix. You may have use Unix Shell script, but have you tried using Windows batch file to help you do the job, for example, getting some log files from a Unix Webserver, without the hassle of typing repeating ftp commands?
There are 2 method.
Method 1:
Create 2 files. 1 is a text file (ftp_cmd.txt) , another is a batch file (ftp_cmd.bat).
ftp_cmd.txt FTPuserLogin FTPuserPassword cd /user/define/location mget userlogfile.log y bye
|
ftp_cmd.bat @echo off ftp -s:ftp_cmd.txt serverhostname
|
Method 2:
Create 1 batch file (ftp_cmd.bat).
ftp_cmd.bat @echo off
echo FTPuserLogin> ftp_cmd.txt echo FTPuserPassword>> ftp_cmd.txt echo cd /user/define/location>> ftp_cmd.txt echo mget userlogfile.log>> ftp_cmd.txt echo y>> ftp_cmd.txt echo bye>> ftp_cmd.txt
ftp -s:ftp_cmd.txt serverhostname
del ftp_cmd.txt
|
Please take note that the batch file cannot be named as
ftp.bat. This will cause confusion between your batch file and ftp command and it will keep on displaying a loop. Every details must not end with a white space.
No comments:
Post a Comment