返回首页
当前位置: 主页 > Linux编程 >

让Shell脚本自动输入参数:转:EXPECT实例 全自动

时间:2011-10-12 10:08来源:未知 作者:masuling 点击:
EXPECT实例全自动ftp匿名登录,下载文件并退出 [root@z ~]# rpm -qa | grep expect [root@z ~]# yum install expect -y [root@z ~]# vi ftptest.sh #!/usr/bin/expect spawn ftp 192.168.1.202 expect Name send ftp\r expect Password: sen
  


 

EXPECT实例 全自动ftp匿名登录,下载文件并退出 

[root@z ~]# rpm -qa | grep expect

[root@z ~]# yum install expect -y

[root@z ~]# vi ftptest.sh

#!/usr/bin/expect
spawn ftp 192.168.1.202
expect "Name"
send "ftp\r"
expect "Password:"
send "nothing\r"
expect "Login successful"
send "cd pub\r"
expect "successfully changed"
send "get shc-3.8.6.tgz\r"
expect "send OK"
send "quit\r"
[root@z ~]# chmod 700 ftptest.sh

[root@z ~]# ./ftptest.sh


顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码: