ftp自动登陆[运维网]
Linux下方法一:
在自己的home目录下建立一个权限600,名为.netrc的文件,内容是:
machine 192.168.0.1 login usertest password testpasswd
这样以后你每次ftp 192.168.0.1的时候,系统都会帮你以用户名usertest,密码testpasswd登录。
利用这个特征可以实现自动ftp。
例如你想要每天5:00到192.168.0.1机器上面获得/test目录下的文件test.txt,可以这么做:
建立一个文件ftp_cmd,内容为:
cd test
get test.txt
bye
然后使用crontab -e设置定时任务:
0 5 * * * ftp 192.168.0.1 < ftp_cmd
方法二:
写脚本
#------------------------------------
#!/bin/sh
ftp -n
页:
[1]