免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2262 | 回复: 1
打印 上一主题 下一主题

ftp 自动下载脚本问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-11-22 13:44 |只看该作者 |倒序浏览
首先想到的是通过$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>
问题写的比较长 请大虾们帮忙 不吝赐教! 非常感谢!

论坛徽章:
0
2 [报告]
发表于 2010-11-23 10:08 |只看该作者
唉 帖子沉了 。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP