1

The program.run I'm trying to run:

  • Asks 2 questions that need the answer "y"
  • Asks a third question at the end which is "press any key to exit"

enter image description here

In addition, it doesn't have the "-y" option. Only this options:

FreeFileSync installation parameters:
-h, --help    Show help
--directory   Change installation directory e.g. --directory /opt/FFS
--noshortcuts  Don't create desktop shortcuts

And neither of these commands work:

yes | sudo ./program.run
yes y | sudo ./program.run
sudo sh -c 'yes y | ./program.run'
echo y | sudo ./program.run
# etc, etc

enter image description here

Since the "yes" command does not seem to work, I would like to try anything else

In this answer, say: "a .run command is simply a set of commands that are going to be run by sh. A particular .run file might take a -y option but in general you can't count on it. If you need to automate some stuff, consider using Expect".

But I don't know how to use Expect. Some help?

Distro: Ubuntu Mate 20.04 LTS

Bash 5.0.17(1)-release (x86_64-pc-linux-gnu)

Update:

I have posted this issue on the official site and the developers announced that in the next version they will add the parameter:

./program.run --accept-license
4
  • How exactly doesn't yes work? Can you post the code of the program you're trying to automate? Feb 16, 2021 at 19:45
  • I don't have the program code. I guess it doesn't recognize my commands, because the questions keep getting when executing them. I have updated the question with the link to the program
    – acgbox
    Feb 16, 2021 at 19:47
  • You have only those 3 questions, or is it a (long/endless) stream of questions?
    – d.c.
    Feb 16, 2021 at 20:19
  • @d.c. I have published an image that answers your question
    – acgbox
    Feb 16, 2021 at 20:38

2 Answers 2

1

In expect that would be:

#!/usr/bin/expect

set timeout -1
log_user 0
spawn ./FreeFileSync_11.6_Install.run
log_user 1

expect -exact "\r
Accept the FreeFileSync license terms? (Enter 's' to show them) \[y/n/s\] "
send -- "y\r"
expect -exact "y\r
Install FreeFileSync into /opt/FreeFileSync? \[Y/n\] "
send -- "Y\r"
expect -exact "https://freefilesync.org/donate\r
\r"

Run:

$ sudo ./expect-script
[sudo] password for user:

Accept the FreeFileSync license terms? (Enter 's' to show them) [y/n/s] y
Install FreeFileSync into /opt/FreeFileSync? [Y/n] Y

-> Installing to: /opt/FreeFileSync
-> New console command: freefilesync
-> Registering file extensions: *.ffs_gui, *.ffs_batch, *.ffs_real

All done!

      (\_/)
  (  =(^Y^)=
   \_(m___m)

Get the Donation Edition with bonus features and help keep FreeFileSync ad-free.
https://freefilesync.org/donate
2
  • yeah. I have no idea how what you just posted works, but it works. Thanks. PS: I suggest you explain a little how that script works
    – acgbox
    Feb 16, 2021 at 21:52
  • You need to learn expect to understand how it works. Feb 16, 2021 at 21:54
0

If I want to provide auto answers for 3 questions as follows:

y< enter >

y< enter >

< enter >

I would use something like:

printf "y\ny\n\n" | sudo ./program.run
5
  • It didn't work. But thanks for the effort in helping me
    – acgbox
    Feb 16, 2021 at 21:10
  • Of course, the program can get rid of any of your "precooked" answers. But what about giving it a second try - simplifying it a bit: first make sudo su and then, run just printf "y\ny\n\n" | ./program.run
    – d.c.
    Feb 16, 2021 at 21:19
  • already did. the same result. the questions continue to appear in an additional window
    – acgbox
    Feb 16, 2021 at 21:33
  • Could you download the program.run in the question link and do the tests? Thanks
    – acgbox
    Feb 16, 2021 at 21:34
  • Well, I am sorry - didn't recognize that it's in different window. Than you can do little about it. Can't replicate either, program is distributed only of x86 arch (and on Mac it's completely different).
    – d.c.
    Feb 16, 2021 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .