expect: does “” (spawn_id exp70) match glob pattern

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have written an expect script that works perfect for testing passwords on our network until it has looped through my list quite a bit, then the debug output shows that there is nothing to match.
Here is some debug that shows the buffer with data in it, then the next spawn with no data:
ssh: connect to host 12.23.34.56 port 22: No route to host
expect: does "ssh: connect to host 12.23.34.56 port 22: No route to hostrrn" (spawn_id exp69) match glob pattern "(yes/no)? "? no
"assword: "? no
"]# "? no
"oute to host"? yes
expect: set expect_out(0,string) "oute to host"
expect: set expect_out(spawn_id) "exp69"
expect: set expect_out(buffer) "ssh: connect to host 12.23.34.56 port 22: No route to host"
spawn ssh -o PreferredAuthentications=password -o NumberOfPasswordPrompts=3 admin@x.x.x.x
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns 26418
expect: does "" (spawn_id exp70) match glob pattern "(yes/no)? "? no
"assword: "? no
"]# "? no
"oute to host"? no
"onnection refused"? no
"isconnected from"? no
expect: timed out
Every spawn_id after exp69 has nothing in the does "" match section.
I think this is related to the buffer some how, but I've tried:
match_max 200000
match_max 600000
And this didn't seem to make any difference. I've removed the real ips and changed it to x.x.x.x. I"m not actually testing x.x.x.x (but the 12.23.34.56 did slip into my list of servers to check)
The script itself is running expect and loops over another file called "servers.txt" and tries line by line to execute a series of commands on that server. It logs what worked and what didn't. Here is what is in the script:
#!/usr/bin/expect
# where to log info, open "writable", this is our homegrown log
# unlike the others that follow
set logfile [open "passcheck-results" "w"]
# clobber and log
log_file -noappend passcheck-logfile
# disable user viewing of process as it happens
# 1=on, 0=off
# disables screen output only, recommended 0
log_user 1
# enable verbose debugging, from expect
# 1=on, 0=off
# useful for debugging the script itself, recommended: 0
exp_internal -f debug.log 0
# default waits for 10s, and if no response, kills process
# too low and machines may not respond fast enough
# in particular real timeouts are not registered if too low
# set to -1 for infinite, real timeouts can take 60s or more
# instead of waiting 60s for EVERY failure, set this lower
# recommend the 10s default
set timeout 10
# if you do not get all the response, you expect, increase buffer
match_max 600000
# get by argv functions instead
# set nohistory save on CLI/bash
set passwords password1 password2 password3
# open the list of servers to process
# warning, no error checking on file open
set input [open "servers.txt" "r"]
# loop over the list of servers with prompt logic
foreach ip [split [read $input] "n"]
# slowing it down a bit
sleep 2
# had to change =password to get results I wanted
# loop over line of servers
spawn ssh -o PreferredAuthentications=password
-o NumberOfPasswordPrompts=[llength $passwords] admin@$ip
# verify where exactly to reset this count
set try 0
# account for other possibilities
expect
"(yes/no)? "
# new host detected
sleep 1
send "yesr"
exp_continue
"assword: "
if $try >= [llength $passwords]
puts $logfile "Bad_Passwords $ip"
#send_error ">>> wrong passwordsn"
exit 1
sleep 1
send [lindex $passwords $try]r
incr try
exp_continue
"]# "
puts $logfile "succeeded_$try $ip"
sleep 1
send "exitr"
"oute to host"
puts $logfile "No_Route_to_Host $ip"
"onnection refused"
puts $logfile "Refused $ip"
"isconnected from"
puts $logfile "Disconnected $ip"
timeout
puts $logfile "timed_out_or_fail $ip"
linux ssh bash shell-script expect
migrated from serverfault.com Jun 13 '15 at 11:04
This question came from our site for system and network administrators.
add a comment |
up vote
0
down vote
favorite
I have written an expect script that works perfect for testing passwords on our network until it has looped through my list quite a bit, then the debug output shows that there is nothing to match.
Here is some debug that shows the buffer with data in it, then the next spawn with no data:
ssh: connect to host 12.23.34.56 port 22: No route to host
expect: does "ssh: connect to host 12.23.34.56 port 22: No route to hostrrn" (spawn_id exp69) match glob pattern "(yes/no)? "? no
"assword: "? no
"]# "? no
"oute to host"? yes
expect: set expect_out(0,string) "oute to host"
expect: set expect_out(spawn_id) "exp69"
expect: set expect_out(buffer) "ssh: connect to host 12.23.34.56 port 22: No route to host"
spawn ssh -o PreferredAuthentications=password -o NumberOfPasswordPrompts=3 admin@x.x.x.x
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns 26418
expect: does "" (spawn_id exp70) match glob pattern "(yes/no)? "? no
"assword: "? no
"]# "? no
"oute to host"? no
"onnection refused"? no
"isconnected from"? no
expect: timed out
Every spawn_id after exp69 has nothing in the does "" match section.
I think this is related to the buffer some how, but I've tried:
match_max 200000
match_max 600000
And this didn't seem to make any difference. I've removed the real ips and changed it to x.x.x.x. I"m not actually testing x.x.x.x (but the 12.23.34.56 did slip into my list of servers to check)
The script itself is running expect and loops over another file called "servers.txt" and tries line by line to execute a series of commands on that server. It logs what worked and what didn't. Here is what is in the script:
#!/usr/bin/expect
# where to log info, open "writable", this is our homegrown log
# unlike the others that follow
set logfile [open "passcheck-results" "w"]
# clobber and log
log_file -noappend passcheck-logfile
# disable user viewing of process as it happens
# 1=on, 0=off
# disables screen output only, recommended 0
log_user 1
# enable verbose debugging, from expect
# 1=on, 0=off
# useful for debugging the script itself, recommended: 0
exp_internal -f debug.log 0
# default waits for 10s, and if no response, kills process
# too low and machines may not respond fast enough
# in particular real timeouts are not registered if too low
# set to -1 for infinite, real timeouts can take 60s or more
# instead of waiting 60s for EVERY failure, set this lower
# recommend the 10s default
set timeout 10
# if you do not get all the response, you expect, increase buffer
match_max 600000
# get by argv functions instead
# set nohistory save on CLI/bash
set passwords password1 password2 password3
# open the list of servers to process
# warning, no error checking on file open
set input [open "servers.txt" "r"]
# loop over the list of servers with prompt logic
foreach ip [split [read $input] "n"]
# slowing it down a bit
sleep 2
# had to change =password to get results I wanted
# loop over line of servers
spawn ssh -o PreferredAuthentications=password
-o NumberOfPasswordPrompts=[llength $passwords] admin@$ip
# verify where exactly to reset this count
set try 0
# account for other possibilities
expect
"(yes/no)? "
# new host detected
sleep 1
send "yesr"
exp_continue
"assword: "
if $try >= [llength $passwords]
puts $logfile "Bad_Passwords $ip"
#send_error ">>> wrong passwordsn"
exit 1
sleep 1
send [lindex $passwords $try]r
incr try
exp_continue
"]# "
puts $logfile "succeeded_$try $ip"
sleep 1
send "exitr"
"oute to host"
puts $logfile "No_Route_to_Host $ip"
"onnection refused"
puts $logfile "Refused $ip"
"isconnected from"
puts $logfile "Disconnected $ip"
timeout
puts $logfile "timed_out_or_fail $ip"
linux ssh bash shell-script expect
migrated from serverfault.com Jun 13 '15 at 11:04
This question came from our site for system and network administrators.
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have written an expect script that works perfect for testing passwords on our network until it has looped through my list quite a bit, then the debug output shows that there is nothing to match.
Here is some debug that shows the buffer with data in it, then the next spawn with no data:
ssh: connect to host 12.23.34.56 port 22: No route to host
expect: does "ssh: connect to host 12.23.34.56 port 22: No route to hostrrn" (spawn_id exp69) match glob pattern "(yes/no)? "? no
"assword: "? no
"]# "? no
"oute to host"? yes
expect: set expect_out(0,string) "oute to host"
expect: set expect_out(spawn_id) "exp69"
expect: set expect_out(buffer) "ssh: connect to host 12.23.34.56 port 22: No route to host"
spawn ssh -o PreferredAuthentications=password -o NumberOfPasswordPrompts=3 admin@x.x.x.x
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns 26418
expect: does "" (spawn_id exp70) match glob pattern "(yes/no)? "? no
"assword: "? no
"]# "? no
"oute to host"? no
"onnection refused"? no
"isconnected from"? no
expect: timed out
Every spawn_id after exp69 has nothing in the does "" match section.
I think this is related to the buffer some how, but I've tried:
match_max 200000
match_max 600000
And this didn't seem to make any difference. I've removed the real ips and changed it to x.x.x.x. I"m not actually testing x.x.x.x (but the 12.23.34.56 did slip into my list of servers to check)
The script itself is running expect and loops over another file called "servers.txt" and tries line by line to execute a series of commands on that server. It logs what worked and what didn't. Here is what is in the script:
#!/usr/bin/expect
# where to log info, open "writable", this is our homegrown log
# unlike the others that follow
set logfile [open "passcheck-results" "w"]
# clobber and log
log_file -noappend passcheck-logfile
# disable user viewing of process as it happens
# 1=on, 0=off
# disables screen output only, recommended 0
log_user 1
# enable verbose debugging, from expect
# 1=on, 0=off
# useful for debugging the script itself, recommended: 0
exp_internal -f debug.log 0
# default waits for 10s, and if no response, kills process
# too low and machines may not respond fast enough
# in particular real timeouts are not registered if too low
# set to -1 for infinite, real timeouts can take 60s or more
# instead of waiting 60s for EVERY failure, set this lower
# recommend the 10s default
set timeout 10
# if you do not get all the response, you expect, increase buffer
match_max 600000
# get by argv functions instead
# set nohistory save on CLI/bash
set passwords password1 password2 password3
# open the list of servers to process
# warning, no error checking on file open
set input [open "servers.txt" "r"]
# loop over the list of servers with prompt logic
foreach ip [split [read $input] "n"]
# slowing it down a bit
sleep 2
# had to change =password to get results I wanted
# loop over line of servers
spawn ssh -o PreferredAuthentications=password
-o NumberOfPasswordPrompts=[llength $passwords] admin@$ip
# verify where exactly to reset this count
set try 0
# account for other possibilities
expect
"(yes/no)? "
# new host detected
sleep 1
send "yesr"
exp_continue
"assword: "
if $try >= [llength $passwords]
puts $logfile "Bad_Passwords $ip"
#send_error ">>> wrong passwordsn"
exit 1
sleep 1
send [lindex $passwords $try]r
incr try
exp_continue
"]# "
puts $logfile "succeeded_$try $ip"
sleep 1
send "exitr"
"oute to host"
puts $logfile "No_Route_to_Host $ip"
"onnection refused"
puts $logfile "Refused $ip"
"isconnected from"
puts $logfile "Disconnected $ip"
timeout
puts $logfile "timed_out_or_fail $ip"
linux ssh bash shell-script expect
I have written an expect script that works perfect for testing passwords on our network until it has looped through my list quite a bit, then the debug output shows that there is nothing to match.
Here is some debug that shows the buffer with data in it, then the next spawn with no data:
ssh: connect to host 12.23.34.56 port 22: No route to host
expect: does "ssh: connect to host 12.23.34.56 port 22: No route to hostrrn" (spawn_id exp69) match glob pattern "(yes/no)? "? no
"assword: "? no
"]# "? no
"oute to host"? yes
expect: set expect_out(0,string) "oute to host"
expect: set expect_out(spawn_id) "exp69"
expect: set expect_out(buffer) "ssh: connect to host 12.23.34.56 port 22: No route to host"
spawn ssh -o PreferredAuthentications=password -o NumberOfPasswordPrompts=3 admin@x.x.x.x
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns 26418
expect: does "" (spawn_id exp70) match glob pattern "(yes/no)? "? no
"assword: "? no
"]# "? no
"oute to host"? no
"onnection refused"? no
"isconnected from"? no
expect: timed out
Every spawn_id after exp69 has nothing in the does "" match section.
I think this is related to the buffer some how, but I've tried:
match_max 200000
match_max 600000
And this didn't seem to make any difference. I've removed the real ips and changed it to x.x.x.x. I"m not actually testing x.x.x.x (but the 12.23.34.56 did slip into my list of servers to check)
The script itself is running expect and loops over another file called "servers.txt" and tries line by line to execute a series of commands on that server. It logs what worked and what didn't. Here is what is in the script:
#!/usr/bin/expect
# where to log info, open "writable", this is our homegrown log
# unlike the others that follow
set logfile [open "passcheck-results" "w"]
# clobber and log
log_file -noappend passcheck-logfile
# disable user viewing of process as it happens
# 1=on, 0=off
# disables screen output only, recommended 0
log_user 1
# enable verbose debugging, from expect
# 1=on, 0=off
# useful for debugging the script itself, recommended: 0
exp_internal -f debug.log 0
# default waits for 10s, and if no response, kills process
# too low and machines may not respond fast enough
# in particular real timeouts are not registered if too low
# set to -1 for infinite, real timeouts can take 60s or more
# instead of waiting 60s for EVERY failure, set this lower
# recommend the 10s default
set timeout 10
# if you do not get all the response, you expect, increase buffer
match_max 600000
# get by argv functions instead
# set nohistory save on CLI/bash
set passwords password1 password2 password3
# open the list of servers to process
# warning, no error checking on file open
set input [open "servers.txt" "r"]
# loop over the list of servers with prompt logic
foreach ip [split [read $input] "n"]
# slowing it down a bit
sleep 2
# had to change =password to get results I wanted
# loop over line of servers
spawn ssh -o PreferredAuthentications=password
-o NumberOfPasswordPrompts=[llength $passwords] admin@$ip
# verify where exactly to reset this count
set try 0
# account for other possibilities
expect
"(yes/no)? "
# new host detected
sleep 1
send "yesr"
exp_continue
"assword: "
if $try >= [llength $passwords]
puts $logfile "Bad_Passwords $ip"
#send_error ">>> wrong passwordsn"
exit 1
sleep 1
send [lindex $passwords $try]r
incr try
exp_continue
"]# "
puts $logfile "succeeded_$try $ip"
sleep 1
send "exitr"
"oute to host"
puts $logfile "No_Route_to_Host $ip"
"onnection refused"
puts $logfile "Refused $ip"
"isconnected from"
puts $logfile "Disconnected $ip"
timeout
puts $logfile "timed_out_or_fail $ip"
linux ssh bash shell-script expect
linux ssh bash shell-script expect
edited Nov 26 at 0:30
Rui F Ribeiro
38.3k1477127
38.3k1477127
asked Jun 11 '15 at 16:24
James
migrated from serverfault.com Jun 13 '15 at 11:04
This question came from our site for system and network administrators.
migrated from serverfault.com Jun 13 '15 at 11:04
This question came from our site for system and network administrators.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
You may be running out of file descriptors. You probably need to call close
on each spawn so you dont run out of resources.
add a comment |
up vote
0
down vote
You were correct, exp_internal -f passcheck-debug.log 1 pointed me to the problem of not having enough ptys. I added:
close -i $spawn_id
wait -nowait
and it continued beyond that point. I had to add -nowait because if it doesn't have a spawn_id it will wait forever.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You may be running out of file descriptors. You probably need to call close
on each spawn so you dont run out of resources.
add a comment |
up vote
0
down vote
You may be running out of file descriptors. You probably need to call close
on each spawn so you dont run out of resources.
add a comment |
up vote
0
down vote
up vote
0
down vote
You may be running out of file descriptors. You probably need to call close
on each spawn so you dont run out of resources.
You may be running out of file descriptors. You probably need to call close
on each spawn so you dont run out of resources.
answered Jun 13 '15 at 18:26
meuh
31.1k11754
31.1k11754
add a comment |
add a comment |
up vote
0
down vote
You were correct, exp_internal -f passcheck-debug.log 1 pointed me to the problem of not having enough ptys. I added:
close -i $spawn_id
wait -nowait
and it continued beyond that point. I had to add -nowait because if it doesn't have a spawn_id it will wait forever.
add a comment |
up vote
0
down vote
You were correct, exp_internal -f passcheck-debug.log 1 pointed me to the problem of not having enough ptys. I added:
close -i $spawn_id
wait -nowait
and it continued beyond that point. I had to add -nowait because if it doesn't have a spawn_id it will wait forever.
add a comment |
up vote
0
down vote
up vote
0
down vote
You were correct, exp_internal -f passcheck-debug.log 1 pointed me to the problem of not having enough ptys. I added:
close -i $spawn_id
wait -nowait
and it continued beyond that point. I had to add -nowait because if it doesn't have a spawn_id it will wait forever.
You were correct, exp_internal -f passcheck-debug.log 1 pointed me to the problem of not having enough ptys. I added:
close -i $spawn_id
wait -nowait
and it continued beyond that point. I had to add -nowait because if it doesn't have a spawn_id it will wait forever.
answered Jun 30 '15 at 19:21
James
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f209409%2fexpect-does-spawn-id-exp70-match-glob-pattern%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown