当前位置: 技术问答>linux和unix
怎样使用批处理来操作FTP命令?
来源: 互联网 发布时间:2015-01-23
本文导语: 怎样使用批处理来操作FTP命令? 用FTP命令从服务器取得一个文件挺麻烦的,如下: Microsoft Windows 2000 [Version 5.00.2195] (C) Copyright 1985-2000 Microsoft Corp. C:>ftp 192.168.0.68 Connected to 192.168.0.68. 220 192.168.0.68 FTP server (luke...
怎样使用批处理来操作FTP命令?
用FTP命令从服务器取得一个文件挺麻烦的,如下:
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:>ftp 192.168.0.68
Connected to 192.168.0.68.
220 192.168.0.68 FTP server (lukemftpd 1.1) ready.
User (192.168.0.68:(none)): plottry
331 Password required for plottry.
Password:
230-
Welcome to Darwin!
230 User plottry logged in.
ftp> ls
. . .
ftp> get 3d.txt
200 PORT command successful.
150 Opening ASCII mode data connection for '3d.ico' (766 bytes).
226 Transfer complete.
ftp: 766 bytes received in 0.02Seconds 38.30Kbytes/sec.
ftp> quit
221-
Data traffic for this session was 766 bytes in 1 file.
Total traffic for this session was 1576 bytes in 2 transfers.
221 Thank you for using the FTP service on 192.168.0.68.
C:>
每次都必须重复输入用户名与密码,我知道可以把这一系列的命令写入批处理文件,但忘了!
谁知道怎样把它写入批处理文件?
(Linux/Unix也差不多,最好不要加入其他Shell命令,只用ftp就行)
用FTP命令从服务器取得一个文件挺麻烦的,如下:
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:>ftp 192.168.0.68
Connected to 192.168.0.68.
220 192.168.0.68 FTP server (lukemftpd 1.1) ready.
User (192.168.0.68:(none)): plottry
331 Password required for plottry.
Password:
230-
Welcome to Darwin!
230 User plottry logged in.
ftp> ls
. . .
ftp> get 3d.txt
200 PORT command successful.
150 Opening ASCII mode data connection for '3d.ico' (766 bytes).
226 Transfer complete.
ftp: 766 bytes received in 0.02Seconds 38.30Kbytes/sec.
ftp> quit
221-
Data traffic for this session was 766 bytes in 1 file.
Total traffic for this session was 1576 bytes in 2 transfers.
221 Thank you for using the FTP service on 192.168.0.68.
C:>
每次都必须重复输入用户名与密码,我知道可以把这一系列的命令写入批处理文件,但忘了!
谁知道怎样把它写入批处理文件?
(Linux/Unix也差不多,最好不要加入其他Shell命令,只用ftp就行)
|
写个脚本,比如:
ftp_usr=yourname
ftp_pwd=youpasswd
ftp_host=192.168.0.68
hostdir=yourdir
file=yourfile
ftp -i -n $ftp_host
ftp_usr=yourname
ftp_pwd=youpasswd
ftp_host=192.168.0.68
hostdir=yourdir
file=yourfile
ftp -i -n $ftp_host