shell except login

#! /usr/bin/expect -f

set ip [ lindex $argv 0 ]
set password
set timeout 5

spawn ssh root@$ip
expect {
      "*yes/no" {send "yes\r";exp_continue}
        "*password:" {send "$password\r"}
}
expect "#*"
send "ls  /export/data/tomcatRoot/\r"
send "chown admin:admin /tmp\r"
#send "sed -n '/server_name/p' /export/servers/nginx/conf/domains/*360buy.com\r"
expect eof

你可能感兴趣的:(shell)