我正在运行以下命令,并且我也使用发送发送响应,但它没有接受任何输入。请告诉我我遗漏了什么?
#!/usr/bin/expect -f
set server_ip "<server?"
spawn ssh -A $server_ip
expect {
"*(RSA) to the list of known hosts.*" {
send "yes\r"
exp_continue
}
"*Ticketing system (JIRA or SNOW):*" {
send "JIRA\r"
}
}
interact
运行expect -d script
输出:
sri@Sreekanth ~ % expect -d jira
expect version 5.45
argv[0] = expect argv[1] = -d argv[2] = jira
set argc 0
set argv0 "jira"
set argv ""
executing commands from command file jira
spawn ssh -A <server>
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {43449}
expect: does "" (spawn_id exp6) match glob pattern "*(RSA) to the list of known hosts.*"? no
"*Ticketing system (JIRA or SNOW):*"? no
Warning: Permanently added '<server>' (RSA) to the list of known hosts.
expect: does "Warning: Permanently added '<server>' (RSA) to the list of known hosts.\r\r\n" (spawn_id exp6) match glob pattern "*(RSA) to the list of known hosts.*"? yes
expect: set expect_out(0,string) "Warning: Permanently added '[<server>' (RSA) to the list of known hosts.\r\r\n"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "Warning: Permanently added '[<server>' (RSA) to the list of known hosts.\r\r\n"
send: sending "yes\r" to { exp6 }
expect: continuing expect
expect: does "" (spawn_id exp6) match glob pattern "*(RSA) to the list of known hosts.*"? no
"*Ticketing system (JIRA or SNOW):*"? no
yes
expect: does "yes\r\n" (spawn_id exp6) match glob pattern "*(RSA) to the list of known hosts.*"? no
"*Ticketing system (JIRA or SNOW):*"? no
Warning: Permanently added '<server>' (RSA) to the list of known hosts.
expect: does "yes\r\nWarning: Permanently added '<server>' (RSA) to the list of known hosts.\r\r\n" (spawn_id exp6) match glob pattern "*(RSA) to the list of known hosts.*"? yes
expect: set expect_out(0,string) "yes\r\nWarning: Permanently added '<server>' (RSA) to the list of known hosts.\r\r\n"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "yes\r\nWarning: Permanently added '<server>' (RSA) to the list of known hosts.\r\r\n"
send: sending "yes\r" to { exp6 }
expect: continuing expect
expect: does "" (spawn_id exp6) match glob pattern "*(RSA) to the list of known hosts.*"? no
"*Ticketing system (JIRA or SNOW):*"? no
yes
expect: does "yes\r\n" (spawn_id exp6) match glob pattern "*(RSA) to the list of known hosts.*"? no
"*Ticketing system (JIRA or SNOW):*"? no
yes
yes
expect: does "yes\r\nyes\r\nyes\r\n" (spawn_id exp6) match glob pattern "*(RSA) to the list of known hosts.*"? no
"*Ticketing system (JIRA or SNOW):*"? no
expect: timed out
tty_raw_noecho: was raw = 0 echo = 1
spawn id exp6 sent <Ticketing system (JIRA or SNOW): >
Ticketing system (JIRA or SNOW): spawn id exp6 sent <Ticketing system (JIRA or SNOW): >
Ticketing system (JIRA or SNOW): spawn id exp6 sent <Ticketing system (JIRA or SNOW): >
Ticketing system (JIRA or SNOW):