linux 中的expect问题,在expect中放入ssh ip "[[ -d /home/bin ]] || mkdir /home/bin",报错:-d有问题
发布网友
发布时间:2022-05-07 00:13
我来回答
共1个回答
热心网友
时间:2023-10-09 07:18
shell的语法在expect下不好使的,把[[ -d /home/bin ]] 改成test -d /home/bin
#!/usr/bin/expect
set timeout 10
set host [lindex $argv 0]
set password [lindex $argv 1]
spawn ssh $host "test -d /home/bin || mkdir /home/bin"
expect {
"(yes/no)?"
{
send "yes\n"
expect "*assword:" { send "$password\n"}
}
"*assword:"
{
send "$password\n"
}
}
expect eof