You are not logged in.

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

misko_2083
Member
Registered: 2016-05-24
Posts: 191

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.

#!/bin/bash

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

Offline

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

ohnonot
...again
Registered: 2015-09-29
Posts: 3,741
Website

Re: expect and UI

misko_2083 wrote:

Is there some good expect tutorial

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

Offline

Board footer

Powered by FluxBB