#!/usr/bin/expect
spawn ssh 填写登录用户名@ip地址
expect "Password:"
send "填写密码\n"
expect "填写登录成功后提示的 $PS1 的值"
send "填写具体的操作,如 cd 到某个目录\n"
expect "操作成功后提示的内容"
send "ls\n"
expect "操作成功后提示的内容"
send "nohup java -jar agent.jar -jnlpUrl http://jenkins/computer/mac_slave/slave-agent.jnlp地址 -secret 具体 secret -workDir '工作目录' &\n\n\n"
expect "操作成功后提示的内容"
send "\n"
expect "操作成功后提示的内容,如:appending output to nohup.out"
send "\n"
expect eof