我有一个期望脚本,我需要在管理节点上每隔3分钟运行一次,以便使用命令收集连接到DCX Brocade SAN Switch的每个端口的tx/rx值#portperfshow#
每次我尝试使用crontab每3分钟执行一次脚本时,脚本不起作用!
我的期望脚本开头,#!/usr/bin/expect -f 我在cron下使用以下语法调用脚本:
3 * * * * /usr/bin/expect -f /root/portsperfDCX1/collect-all.exp sanswitchhostname
Run Code Online (Sandbox Code Playgroud)
但是,当我执行脚本(不在cron下)时,它按预期工作:
root# ./collect-all.exp sanswitchhostname
Run Code Online (Sandbox Code Playgroud)
工作得很好.
请有人帮忙!谢谢.
脚本collect-all.exp是:
#!/usr/bin/expect -f
#Time and Date
set day [timestamp -format %d%m%y]
set time [timestamp -format %H%M]
#logging
set LogDir1 "/FPerf/PortsLogs"
et timeout 5
set ipaddr [lrange $argv 0 0]
set passw "XXXXXXX"
if { $ipaddr == "" } {
puts "Usage: <script.exp> <ip address>\n"
exit 1
}
spawn ssh admin@$ipaddr
expect …Run Code Online (Sandbox Code Playgroud)