You are not logged in.

#1 2019-06-11 21:33:40

Registered: 2016-05-24
Posts: 299

expect and UI

Let's see.
Many distros use the terminal to upgrade the system with the simple "apt update && apt-dist upgrade".
That has it's advantages because the  user can interact with the terminal answering Y/n questions, it warns the user of what is about to happen, etc.

Now piping the apt to the yad dialog prints what is happening with apt but doesn't allow the user interaction.

(apt update 2>&1 && apt install expect) | yad --text-info

Combining the terminal and graphical user interface to answer yes/no questions or to enter the password could make things easier.
Is this possible to achieve with expect?

I'm not familiar with the syntax of expect,
so this is just my clumsy attempt.
With expect installed and if next script is run in the terminal
a yad "password" dialog appears and if you enter the password apt update runs.


/usr/bin/expect <<EOF
    spawn bash -c "sudo apt update 2>&1"
    expect {
       ": $" {
       send -- "$(/usr/bin/yad --form --field="Password":H --separator=)"
       send -- "\r"
    expect eof

Now the question.
How to handle the error, if no password is entered?
How open the dialog again if a wrong password is entered?
Is there some good expect tutorial online?

Што ни оштровиди ум сагледати не може - љубав превазилази.


#2 2019-06-12 08:09:45

Registered: 2015-09-29
Posts: 4,310

Re: expect and UI

misko_2083 wrote:

Is there some good expect tutorial

if you can't find one:
i have no experience with expect either, but it pops up on LQ ever so often.


Board footer

Powered by FluxBB