Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNIX Expect Spawn

Status
Not open for further replies.

etphonehome2

IS-IT--Management
May 15, 2004
4
US
I have a sftp command which requires the passing of parameters to sftp in order for it to work:

sftp -o "ProxyCommand nc -X 5 -x Server_Name:1080 %h %p" userid@IP_Address

In Expect, how do I pass the quotes to spawn? When I put quotes, it does not seem to keep it:

spawn sftp -o "ProxyCommand nc -X 5 -x Server_Name:1080 %h %p" userid@IP_Address

 
The following was generated when used
#!/usr/bin/expect -f
exp_internal 1
spawn sftp -o 'ProxyCommand nc -X 5 -x Server_Name:1080 %h %pa' userid@IP_Address
expect "*?assword:"
send "XXXXX\n"
interact


spawn sftp -o 'ProxyCommand nc -X 5 -x Server_Name:1080 %h %pa' userid@IP_Address
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {12116}

expect: does "" (spawn_id exp6) match glob pattern "*?assword:"? no
usage: sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]
[-o ssh_option] [-P sftp_server_path] [-R num_requests]
[-S program] [-s subsystem | sftp_server] host
sftp [[user@]host[:file [file]]]
sftp [[user@]host[:dir[/]]]
sftp -b batchfile [user@]host

expect: does "usage: sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]\r\n [-o ssh_option] [-P sftp_server_path] [-R num_requests]\r\n [-S program] [-s subsystem | sftp_server] host\r\n sftp [[user@]host[:file [file]]]\r\n sftp [[user@]host[:dir[/]]]\r\n sftp -b batchfile [user@]host\r\n" (spawn_id exp6) match glob pattern "*?assword:"? no
expect: read eof
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "usage: sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]\r\n [-o ssh_option] [-P sftp_server_path] [-R num_requests]\r\n [-S program] [-s subsystem | sftp_server] host\r\n sftp [[user@]host[:file [file]]]\r\n sftp [[user@]host[:dir[/]]]\r\n sftp -b batchfile [user@]host\r\n"
....
....
 
Have you tried escaping them with backslash?

Code:
spawn sftp -o \"ProxyCommand nc -X 5 -x Server_Name:1080 %h %p\" userid@IP_Address

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top