Skip to content

Instantly share code, notes, and snippets.

@cammckinnon
Created November 29, 2011 06:25
Show Gist options
  • Save cammckinnon/1403695 to your computer and use it in GitHub Desktop.
Save cammckinnon/1403695 to your computer and use it in GitHub Desktop.
#!/usr/bin/expect -f
set user [lindex $argv 0]
set pass [lindex $argv 1]
set file1 [lindex $argv 2]
set file2 [lindex $argv 3]
spawn scp $file1 $file2 $user@linux.student.cs.uwaterloo.ca:~
expect "*?password:*"
send "$pass\r"
send "\r"
expect eof
spawn ssh $user@linux.student.cs.uwaterloo.ca
expect "*?password:*"
send "$pass\r"
expect "*>*"
send "cd ~\r"
expect "*>*"
send "source /u/cs241/setup\r"
expect "*>*"
send "cs241.linker $file1 $file2 > final.merl\r"
expect {
"*ERROR*" {
send "exit\r" ;
expect eof
exit 2
}
"*>*" {
send "java cs241.merl 0 < final.merl > final.mips\r"
expect "*>*"
send "exit\r"
expect eof
spawn scp $user@linux.student.cs.uwaterloo.ca:~/final.mips .
expect "*?password:*"
send "$pass\r"
send "\r"
expect eof
exit 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment