I've spent the better part of the day now searching everywhere for an answer, and nothing has worked so far. What I'm trying to do is run an expect script that will attach to a GNU screen session, send it the command line arguments (a command), and output the result of that one command. So far this is one of my scritps:
#!/usr/bin/expect -f
set timeout 3
#exp_internal 1
spawn screen -raAd call_sess
sleep 1
expect -re "\\\$" {
send $argv
send "\n"
sleep 1
}
expect -re ".*" {
set output $expect_out(0,string)
}
expect "\$" {
send "\001"
send "d"
}
expect eof {
puts "OUTPUT---------------"
puts $output
puts "OUTPUT---------------"
}
And $expect_out(0,string) only matches a newline, even though .* should match everything since the last match. If anyone could help me get this working that would be awesome, I'm about ready to give up and call it impossible.
EDIT: Answered in the comments, but I should have specified that the command does get run in the screen, I just can't capture the output correctly.
EDIT2: Changed the script to spawn screen as suggested, thanks!