This is the first time I have done an expect script. In principle it is a simple script
#!/usr/bin/expect
set timeout 200
spawn XXX/bin/PROGRAM
expect "Choose an option ..."
send "1\r"
...
The program has several options, and I have made 4 similar scripts with them that have not given problems, in addition, in the option that gives problems I also navigate through a series of submenus without problems.
The problem appears at a certain point when the program I have spawned throws the message:
nohup: appending output to 'nohup.out'
The problem always occurs in an expect-send block where the program kills a number of processes.
When I run the program directly from the command line I don't get this problem, so I understand that the problem is related to the output directioning of the process created by spawn, I have tried several ways to solve this but all without success.
How can I make the process created by the expect script behave in the same way as in my terminal and avoid the redirecting to nohup?
Thank you very much.
I managed to find a solution and I answer myself.
The error was indeed in the process that the script created for the program, because as I said it behaved differently (someone commented that this is what happened too).
To solve it I simply spawned a terminal, and from the terminal I launched the program, so the behaviour is the same.
#!/usr/bin/expect
set timeout 200
spawn $env(SHELL)
match_max 100000
send -- "XXX/bin/PROGRAM\r"
expect "Choose an option ..."
send "1\r"
...
I hope this helps if you encounter a similar problem.