- 论坛徽章:
- 0
|
首先想到的是通过$home/.netrc 来实现自动下载
.netrc的内容
machine 192.168.0.6
login viualadmin
password 123
macdef init
binary
prompt off
hash on
cd dep1/test_in_dep1
mget putty.exe
bye(如果这里不写bye的话完成后不会退出ftp>)
chmod 600 .netrc
在命令行提示符后打ftp 192.168.0.6 能成功实现自动下载putty.exe
当我把machine 这行去掉后
[useputty_login@Server1 ~]$ftp 192.168.0.6
Connected to 192.168.0.6.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (192.168.0.6:useputty_login):
就会提示你输入用户名和密码然后我怀疑是不是一定需要machine这一行呢?
man netrc有如下:
machine name
Identify a remote machine name. The auto-login process
searches the .netrc file for a machine token that matches the
remote machine specified on the ftp command line or as an open
command argument. Once a match is made, the subsequent .netrc
tokens are processed, stopping when the end of file is reached
or another machine or a default token is encountered.
貌似后面说一旦machine 后的ftp服务器主机名 或者ip与命令行上的主机名或者是ip地址即ftp后192.168.0.6相匹配时才会执行
(或者说读取执行.netrc文件后面的内容)
小弟不知道我这里理解的对不对请各位大虾指正下!?
password string
Supply a password. If this token is present, the auto-login
process will supply the specified string if the remote server
requires a password as part of the login process. Note that if
this token is present in the .netrc file for any user other
than anonymous, ftp will abort the auto-login process if the
.netrc is readable by anyone besides the user
还有小弟通过这段话明白了为什么要把.netrc的权限改成600。最后一句说如果.netrc 如果对除该用户之外的其他用户可读
自动登录程序就会退出
2 是想通过脚本来实现下载
在ftp.cmd中写入
open 192.168.0.6 21
user username password
binary
prompt off
hash on
cd dep1/test_in_dep1
mget putty.exe
(注意这里小弟没有写bye 也就是小弟后面的疑问之处)
命令行: ftp -n <ftp.cmd(这里-n是用来跳过.netrc文件)
[useputty_login@Server1 ~]$ftp -n<ftp.sh
Please login with USER and PASS.
Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Interactive mode off.
Hash mark printing on (1024 bytes/hash mark).
############################################################################################################################################################################################################################################################################################################################################################################################################################################################
[useputty_login@Server1 ~]$
小弟的疑问是我在ftp.cmd没有写bye这个ftp命令 为什么为自动跳出ftp>呢 ?而不像.netrc一样如果没写bye的话
会停留在ftp>
问题写的比较长 请大虾们帮忙 不吝赐教! 非常感谢! |
|