Re: expect and spawn

2010-11-13 Thread Aaron Martinez
On Tue, 2010-11-09 at 12:11 -0800, Jim Lucas wrote:
 On 11/9/2010 12:00 PM, Aaron Martinez wrote:
  On Tue, Nov 09, 2010 at 09:48:15AM -0600, Aaron Martinez wrote:
  I am trying to use openbsd as my workstation here at work but one of the
  tools we use, creates an expect script and it's not working at all.  The
  developer of the tool uses linux primarily so he's not sure except to
  tell me that the expect in openbsd doesn't know spawn which I looked and
  the expect man page is loaded with stuff about spawn.
 
  The script I try to run is this:
  # cat 227254.test
 
  #!/usr/local/bin/expect -f
  set timeout -1
  spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o \
  UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no \
  r...@192.168.0.10
  interact {
  \034 exit
  }
 
 
  Executing this from the command line returns the following:
 
  # sh -x 227254.test
 
  When invoked like this, the interpreter is sh, not expect.
 
  --
 
  Will Maier
  http://will.m.aier.us/
 
 
  
  
  Thanks Will,
  
  silly question, how would then I do a good test?
  
  Thanks.
  
  Aaron
  
 
 # chmod 0744 227254.test
 # ./227254.test
 

Ok,

I was able to test this simplified script and it works just fine when I
run it, the output is below.  The problem arises when I try to execute
the full script which is:

$ cat expect_full.test
#!/usr/local/bin/expect -f
set timeout -1
spawn -noecho ssh -X -vvv -p 22 -l test -o StrictHostKeyChecking=no \
 -o UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no 192.168.0.10
match_max 10
expect assword
sleep .1
send -- tester\r
expect {
-re ]|test|\$
}
sleep .1
send -- export LANG=en_US.UTF-8\r
expect -re ]|test|\$
sleep .1
send -- su -\r
expect assword
sleep .1
send -- root_tester\r
expect -re #|assword|root|ROOT|%
sleep .1
send -- export LANG=en_US.UTF-8\r
expect -re ]|root|#
sleep .1
trap { stty rows [stty rows] columns [stty columns] \
 $spawn_out(slave,name)} WINCH
interact {
 \034 exit
}

--
I get brought back to what looks to be a password prompt but then when i
try to type a password it actually prints whatever I type right on the
screen.  Hitting enter does nothing and the session just sits there
indefinitely.

Just a bit more information, I am connecting from an OpenBSD 4.8 system
to a RedHat 5.5 system.

The output when executing the full script is also below.

Output from simple script:
$ ./expect_simple_ssh_verbose.test
OpenSSH_5.6, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /home/apmartinez/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.0.10 [192.168.0.10] port 22.
debug1: Connection established.
debug1: identity file /home/apmartinez/.ssh/id_rsa type -1
debug1: identity file /home/apmartinez/.ssh/id_rsa-cert type -1
debug1: identity file /home/apmartinez/.ssh/id_dsa type -1
debug1: identity file /home/apmartinez/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug2: fd 5 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit:
diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit:
ssh-rsa-cert-...@openssh.com,ssh-dss-cert-...@openssh.com,ssh-rsa-cert-...@openssh.com,ssh-dss-cert-...@openssh.com,ssh-rsa,ssh-dss
debug2: kex_parse_kexinit:
aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-...@lysator.liu.se
debug2: kex_parse_kexinit:
aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-...@lysator.liu.se
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,umac...@openssh.com,hmac-ripemd160,hmac-ripemd...@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit:
hmac-md5,hmac-sha1,umac...@openssh.com,hmac-ripemd160,hmac-ripemd...@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,z...@openssh.com,zlib
debug2: kex_parse_kexinit: none,z...@openssh.com,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit:
diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit:
aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-...@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit:

expect and spawn

2010-11-09 Thread Aaron Martinez
Hi All,

I am trying to use openbsd as my workstation here at work but one of the
tools we use, creates an expect script and it's not working at all.  The
developer of the tool uses linux primarily so he's not sure except to
tell me that the expect in openbsd doesn't know spawn which I looked and
the expect man page is loaded with stuff about spawn.

The script I try to run is this:
# cat 227254.test   
 
#!/usr/local/bin/expect -f
set timeout -1
spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o \
UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no \
r...@192.168.0.10
interact {
\034 exit
}


Executing this from the command line returns the following:

# sh -x 227254.test

+ set timeout -1
+ spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o
UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no
r...@192.168.0.10
227254.test[3]: spawn: not found
+ interact {
227254.test[4]: interact: not found
+ 034 exit
227254.test[5]: 034: not found
227254.test[6]: syntax error: `}' unexpected


Is the format of his expect script all wrong or?? 

Thanks,

Aaron Martinez



Re: expect and spawn

2010-11-09 Thread paul branston

On 11/09/10 15:48, Aaron Martinez wrote:

Hi All,

I am trying to use openbsd as my workstation here at work but one of the
tools we use, creates an expect script and it's not working at all.  The
developer of the tool uses linux primarily so he's not sure except to
tell me that the expect in openbsd doesn't know spawn which I looked and
the expect man page is loaded with stuff about spawn.

The script I try to run is this:
# cat 227254.test

#!/usr/local/bin/expect -f
set timeout -1
spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o \
UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no \
r...@192.168.0.10
interact {
\034 exit
}


Executing this from the command line returns the following:

# sh -x 227254.test

+ set timeout -1
+ spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o
UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no
r...@192.168.0.10
227254.test[3]: spawn: not found
+ interact {
227254.test[4]: interact: not found
+ 034 exit
227254.test[5]: 034: not found
227254.test[6]: syntax error: `}' unexpected


Is the format of his expect script all wrong or??

Thanks,

Aaron Martinez


   
 This might be a silly question but have you installed expect from the 
ports?  Also expect depends on tl and tcl which will be installed which 
are installed along with expect.


regards,

Paul



Re: expect and spawn

2010-11-09 Thread Will Maier
On Tue, Nov 09, 2010 at 09:48:15AM -0600, Aaron Martinez wrote:
 I am trying to use openbsd as my workstation here at work but one of the
 tools we use, creates an expect script and it's not working at all.  The
 developer of the tool uses linux primarily so he's not sure except to
 tell me that the expect in openbsd doesn't know spawn which I looked and
 the expect man page is loaded with stuff about spawn.
 
 The script I try to run is this:
 # cat 227254.test   
  
 #!/usr/local/bin/expect -f
 set timeout -1
 spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o \
 UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no \
 r...@192.168.0.10
 interact {
 \034 exit
 }
 
 
 Executing this from the command line returns the following:
 
 # sh -x 227254.test

When invoked like this, the interpreter is sh, not expect.

-- 

Will Maier
http://will.m.aier.us/



Re: expect and spawn

2010-11-09 Thread Aaron Martinez
 On Tue, Nov 09, 2010 at 09:48:15AM -0600, Aaron Martinez wrote:
 I am trying to use openbsd as my workstation here at work but one of the
 tools we use, creates an expect script and it's not working at all.  The
 developer of the tool uses linux primarily so he's not sure except to
 tell me that the expect in openbsd doesn't know spawn which I looked and
 the expect man page is loaded with stuff about spawn.

 The script I try to run is this:
 # cat 227254.test

 #!/usr/local/bin/expect -f
 set timeout -1
 spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o \
 UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no \
 r...@192.168.0.10
 interact {
 \034 exit
 }


 Executing this from the command line returns the following:

 # sh -x 227254.test

 When invoked like this, the interpreter is sh, not expect.

 --

 Will Maier
 http://will.m.aier.us/




Thanks Will,

silly question, how would then I do a good test?

Thanks.

Aaron



Re: expect and spawn

2010-11-09 Thread Aaron Martinez
 On 11/09/10 15:48, Aaron Martinez wrote:
 Hi All,

 I am trying to use openbsd as my workstation here at work but one of the
 tools we use, creates an expect script and it's not working at all.  The
 developer of the tool uses linux primarily so he's not sure except to
 tell me that the expect in openbsd doesn't know spawn which I looked and
 the expect man page is loaded with stuff about spawn.

 The script I try to run is this:
 # cat 227254.test

 #!/usr/local/bin/expect -f
 set timeout -1
 spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o \
 UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no \
 r...@192.168.0.10
 interact {
 \034 exit
 }


 Executing this from the command line returns the following:

 # sh -x 227254.test

 + set timeout -1
 + spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o
 UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no
 r...@192.168.0.10
 227254.test[3]: spawn: not found
 + interact {
 227254.test[4]: interact: not found
 + 034 exit
 227254.test[5]: 034: not found
 227254.test[6]: syntax error: `}' unexpected


 Is the format of his expect script all wrong or??

 Thanks,

 Aaron Martinez



   This might be a silly question but have you installed expect from the
 ports?  Also expect depends on tl and tcl which will be installed which
 are installed along with expect.

 regards,

 Paul



Hi Paul,

I do have expect installed but not via ports, I just used the packages.

Thanks.

Aaron



Re: expect and spawn

2010-11-09 Thread Aaron Martinez
 On 11/9/2010 12:00 PM, Aaron Martinez wrote:
 On Tue, Nov 09, 2010 at 09:48:15AM -0600, Aaron Martinez wrote:
 I am trying to use openbsd as my workstation here at work but one of
 the
 tools we use, creates an expect script and it's not working at all.
 The
 developer of the tool uses linux primarily so he's not sure except to
 tell me that the expect in openbsd doesn't know spawn which I looked
 and
 the expect man page is loaded with stuff about spawn.

 The script I try to run is this:
 # cat 227254.test

 #!/usr/local/bin/expect -f
 set timeout -1
 spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o \
 UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no \
 r...@192.168.0.10
 interact {
 \034 exit
 }


 Executing this from the command line returns the following:

 # sh -x 227254.test

 When invoked like this, the interpreter is sh, not expect.

 --

 Will Maier
 http://will.m.aier.us/




 Thanks Will,

 silly question, how would then I do a good test?

 Thanks.

 Aaron


 # chmod 0744 227254.test
 # ./227254.test


wow, I guess i should have just tried that before asking.  Unfortunately
i'm heading out of town to a funeral won't be able to test it until
tomorrow.

Thanks jim,

Aaron



Re: expect and spawn

2010-11-09 Thread Jim Lucas
On 11/9/2010 12:00 PM, Aaron Martinez wrote:
 On Tue, Nov 09, 2010 at 09:48:15AM -0600, Aaron Martinez wrote:
 I am trying to use openbsd as my workstation here at work but one of the
 tools we use, creates an expect script and it's not working at all.  The
 developer of the tool uses linux primarily so he's not sure except to
 tell me that the expect in openbsd doesn't know spawn which I looked and
 the expect man page is loaded with stuff about spawn.

 The script I try to run is this:
 # cat 227254.test

 #!/usr/local/bin/expect -f
 set timeout -1
 spawn -noecho ssh -X -vvv -p 22 -o StrictHostKeyChecking=no -o \
 UserKnownHostsFile=/dev/null -o GSSAPIAuthentication=no \
 r...@192.168.0.10
 interact {
 \034 exit
 }


 Executing this from the command line returns the following:

 # sh -x 227254.test

 When invoked like this, the interpreter is sh, not expect.

 --

 Will Maier
 http://will.m.aier.us/


 
 
 Thanks Will,
 
 silly question, how would then I do a good test?
 
 Thanks.
 
 Aaron
 

# chmod 0744 227254.test
# ./227254.test



Re: expect and spawn

2010-11-09 Thread Andy Bradford
Thus said Aaron Martinez on Tue, 09 Nov 2010 09:48:15 CST:

 # sh -x 227254.test

Why are you telling sh to interpret an expect script? Why not try:

$ expect 227254.text

 227254.test[3]: spawn: not found
 + interact {
 227254.test[4]: interact: not found
 + 034 exit
 227254.test[5]: 034: not found
 227254.test[6]: syntax error: `}' unexpected

These  errors are  all  produced by  sh.  sh is  trying  to execute  the
commands in 227254.test  and is it any wonder that  it doesn't recognize
the words spawn, interact, 034, and says there is a syntax error?

 Is the format of his expect script all wrong or??

No, you are using the wrong interpreter.

Andy