My command line/bash fu is extremely weak, but I'm trying to hone my abilities. Hopefully someone can help.
I wrote a super simple
expect script so that I can SSH in to a headless box we're using at work, while also sending in the password (for reasons that I am unable to expand upon, we can't use public keys to automate logging in). The script:
#!/usr/bin/expect -f set timeout 30 spawn ssh -X ***@10.101.0.133 $argv match_max 100000 expect "*?assword:*" send -- "***\r" interact
The box has a developer environment and Eclipse installed; most of the time that I'm connecting to it, I will end up tunneling straight in to Eclipse to work on some code that we keep on this box, so I usually end up using
How can I pass the
& flag in to expect so that it sees the ampersand as an argument for the ssh session I'm spawning ? When I use
script eclipse & it just backgrounds script on my machine instead of doing something on the remote machine, but I'd like to be able to send the
& in to
script so that when Eclipse launches on the remote box I can still use the box's shell.
This is probably an incredibly silly question, but any help would be greatly appreciated.
Update: I figured out escaping the ampersand (which was definitely a "no duh" moment for me... meh). But this leads to a new problem. It seems that when I pass any arguments to my script, the expect command never allows me to interact; once the passed command executes the SSH session terminates. I'm guessing that this isn't a limitation of expect but a part of the behavior of ssh. Thanks for your answers though.
Update 2: Just for the sake of posterity, I got the behavior I wanted by modifying the script to look like this:
#!/usr/bin/expect -f set timeout 30 spawn ssh -X ***@10.101.0.133 match_max 100000 expect "*?assword:*" send -- "***\r" send $argv send -- "\r" interact