# Expect Command Sequence Template
# Adjust paths and prompt as needed
# Expect Homepage: http://expect.nist.gov/

set prompt "(#|\\$|>) $"  ;# regular expression describing the prompt
set timeout -1            ;# infinite timeout
spawn telnet %h           ;# open a telnet session to the host
expect -nocase login:     ;# wait for login prompt
send "%u\r"               ;# send username
expect -nocase password:  ;# wait for password prompt
send "%p\r"               ;# send password
expect -re $prompt        ;# wait for telnet prompt
send "cd %d\r"            ;# change to directory with application
expect -re $prompt        ;# wait for prompt
send "chmod 755 %b\r"     ;# make file executable
expect -re $prompt        ;# wait for prompt
send "./%b %a\r"          ;# start the application (e.g.: './a.out arg1')
expect -re $prompt        ;# wait for the application to terminate
send "exit\r"             ;# logout
send_user "\n"