Score:0

Automate process that needs user interaction not working in ubuntu using expect package

ca flag

I want to automate the running of a process in Ubuntu using Expect.

The process that I have asks the user to insert "ok" and then ask them to insert a password.

I've created an Expect script to automate the operation

#!/usr/bin/expect -f

spawn -ignore HUP /home/startclef.cmd

expect "ok"

send "ok\r"

sleep 5

expect "Please enter the password to decrypt the master seed"

sleep 5

send "pass_123\r"

sleep 5

interact

expect_background

I stored the previous script in a file named script.expect

When I execute the script in this way

./script.expect 

it's working perfectly, but I want to run the process in the background so I executed the script in this way:

./script.expect &

it returns an error

liner: function not supported in this terminal
waltinator avatar
it flag
Remove the `sleep 5`s. `expect` will wait on your behalf.
waltinator avatar
it flag
The error message comes from `startclef.cmd`. It doesn't like the value of the `TERM` environment variable. Check it with `echo $TERM` on your terminal and inside `startclef.cmd`.
waltinator avatar
it flag
It's easier to have `expect` turn off echo, and prompt for the password itself.
cn flag
duplicate of https://stackoverflow.com/q/76628037/7552
Abdulhamid avatar
ca flag
@waltinator please note that the script works if I execute it directly not with (&). The issue appears just if I run the script in the background.
Abdulhamid avatar
ca flag
I want to run this process on the system startup which is why I want to make it automatic and run in the background
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.