您的位置:首页 > 运维架构 > Linux

linux中判定远程目录是否存在

2014-02-08 09:30 253 查看
#!/usr/bin/expect -f

set username [lindex $argv 0]

set passwd [lindex $argv 1]

set destIP [lindex $argv 2]

 

set destDIR [lindex $argv 3]

set timeout 15

   spawn ssh  $username@$destIP

expect {

    "(yes/no)?" {  send "yes\n";exp_continue}

    "*assword*" {  send "$passwd\n";exp_continue }

    "*assword*" {  send "exit 1 \n"    } 

     }

expect "#"

send "mkdir -p /tmp/testSendLog\n"

expect "#"

send "test -d $destDIR\n"

expect "#"

send "echo $? > /tmp/testSendLog/text.txt\n"

expect "#"

send "exit\r"

expect eof
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: