Chinaunix
标题:
FTP脚本求助
[打印本页]
作者:
sea987
时间:
2013-08-27 00:16
标题:
FTP脚本求助
大家好,情景:solaris终端机FTP到某一个网段10多台solaris服务器上的相同目录抓取2个文件,且每个服务器的这两个文件名相同;需求:在终端机上自动建立这10多台服务器Hostname的文件夹,且将各自服务器文件ftp到对应的目录。请大家提供下思路,有现成脚本更好。谢谢大家!
作者:
rdcwayx
时间:
2013-08-27 06:45
本帖最后由 rdcwayx 于 2013-08-27 08:45 编辑
HOST='ftp.users.net'
USER='yourid'
PASSWD='yourpw'
FILE='file.txt'
for HOST in server1 server2 serverx ....
do
#FTP
ftp $HOST <<END_SCRIPT
user $USER
$PASSWD
put $FILE
quit
END_SCRIPT
done
复制代码
作者:
donalds2008
时间:
2013-08-27 11:28
#!/bin/bash
usr="xx";#user
pwd="xx";#password
get_file="xx";#file
ip_file="ip.list"#server ip list
expect <<EOF
set timeout 3
set list_ip [open $ip_file r]
while {[gets \$list_ip ip ] != -1} {
exec mkdir \$ip
spawn ftp \$ip
expect "Name"
send "$usr\r"
expect "*ssword"
send "$pwd\r"
expect "ftp>"
send "cd dir\r"
expect "ftp>"
send "get $get_file \$ip/$get_file \r"
expect "ftp>"
send "quit\r"
}
expect eof
EOF
作者:
donalds2008
时间:
2013-08-27 11:28
#!/bin/bash
usr="xx";#user
pwd="xx";#password
get_file="xx";#file
ip_file="ip.list"#server ip list
expect <<EOF
set timeout 3
set list_ip [open $ip_file r]
while {[gets \$list_ip ip ] != -1} {
exec mkdir \$ip
spawn ftp \$ip
expect "Name"
send "$usr\r"
expect "*ssword"
send "$pwd\r"
expect "ftp>"
send "cd dir\r"
expect "ftp>"
send "get $get_file \$ip/$get_file \r"
expect "ftp>"
send "quit\r"
}
expect eof
EOF
复制代码
作者:
秋天的絮儿
时间:
2013-08-27 15:55
ftp -niv <<END
open HOST
user xxx xxxx
binary y
lcd /xxxx
put xxx.txt
close
END
ftp -niv <<END
open HOST
user xxx xxxx
binary y
lcd /xxxx
put xxx.txt
close
END
...........................
复制代码
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2