- 论坛徽章:
- 0
|
新问题(本来不好意思再问,搞不定啊,还是要请教waver大哥!)
假如需要程序一传递两个参数给程序二,这时候应该怎么处理呢?我简单的修改了一下上面的脚本,请看
程序一:name.sh
#!/bin/bash
server=10.0.0.1
for name in root1 root2 root3
do
./login.exp $name $server
done
程序二:login.exp
#!/user/bin/expect -f
set $argv0 [lrange $argv 0 1]
spawn ssh $argv0@$argv1
expect "yes/no";
send "yes\r";
expect "password:"
sent "123456";
interact;
执行:
#./name.sh
发生错误:can't read argv1,no such varable
假如修改程序二
程序二:login.exp
#!/user/bin/expect -f
set $argv0 [lrange $argv 0 1]
spawn ssh $argv@$argv
expect "yes/no";
send "yes\r";
expect "password:"
sent "123456";
interact;
执行后,发生错误:
spwan ssh root 10.0.0.1@ssh root 10.0.0.1
ssh name or serice not kown |
|