I've tried using some bash commands in an expect script before spawning anything, and this doesn't seem to work:
#!/usr/bin/expect
sudo ifdown usb0
sudo ifup usb0
expect "[sudo] password for stud:"
send "FirstPassword\r"
spawn ssh root@10.9.8.2
expect "root@10.9.8.2's password:"
send "SecondPassword\r"
expect eof
I've tried running this with the first part of the script commented out (because it's not neccesary to do this check 100% of the time, just better), but in that case I enter the device, and literally can't do anything there. I'd like to ifdown ifup, enter pass, ssh, enter pass, and scope to that shell.