3个回答
展开全部
登录并备份到tftp的脚本是这个奶奶样的:
#!/usr/bin/expect
spawn telnet 10.21.10.233
expect "*sername*"
send "admin\r"
expect "*asswor*"
send "******\r"
send "en\r"
expect "*assw*"
send "*******\r"
send "copy running-config startup-config\r"
expect "*estination filename*"
send "\r"
send "copy startup-config tftp:\r"
expect "*ddress or name of remote host*"
send "10.21.10.110\r"
expect "*estination filename*"
send [exec date +C2950_BJ95-20%y%m%d].config\r
sleep 10
send "exit\r"
send "\r"
#!/usr/bin/expect
spawn telnet 10.21.10.233
expect "*sername*"
send "admin\r"
expect "*asswor*"
send "******\r"
send "en\r"
expect "*assw*"
send "*******\r"
send "copy running-config startup-config\r"
expect "*estination filename*"
send "\r"
send "copy startup-config tftp:\r"
expect "*ddress or name of remote host*"
send "10.21.10.110\r"
expect "*estination filename*"
send [exec date +C2950_BJ95-20%y%m%d].config\r
sleep 10
send "exit\r"
send "\r"
展开全部
以下脚本可以使用telnet远程登录指定的主机,并获取远程主机执行命令的返回结果保存为本地文件。此脚本是一种实现方法,暂只支持返回一个命令的结果。
#!/bin/ksh
USER="admin"
PASSWORD="password"
LOGFILE="`pwd`/test.log`date +%m%d%y`"
SLEEPCOUNT="2"
HOSTNAME=192.168.1.30
COMMAND="df -h"
( echo $USER ;
sleep $SLEEPCOUNT ;
echo $PASSWORD ;
sleep $SLEEPCOUNT ;
echo $COMMAND ;
sleep $SLEEPCOUNT ;
exit ) | telnet $HOSTNAME > $LOGFILE
#!/bin/ksh
USER="admin"
PASSWORD="password"
LOGFILE="`pwd`/test.log`date +%m%d%y`"
SLEEPCOUNT="2"
HOSTNAME=192.168.1.30
COMMAND="df -h"
( echo $USER ;
sleep $SLEEPCOUNT ;
echo $PASSWORD ;
sleep $SLEEPCOUNT ;
echo $COMMAND ;
sleep $SLEEPCOUNT ;
exit ) | telnet $HOSTNAME > $LOGFILE
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
请百度 :expect的用法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |