5

I want to use autoexpect for a simple .sh file but the terminal shows this error:

can't find package Expect
    while executing
"package require Expect"
    (file "/usr/bin/autoexpect" line 6)

my terminal command is:

autoexpect shell.sh

I remove expect and install it again but no difference with past!

Can anyone help me?

already newest version

This is output of dpkg -l | grep tcl; which tclsh; which tclsh8.6; dpkg -S Expect; echo $PATH. Does Anaconda contradict expect?

installed, anaconda path

Zanna
  • 70,465
Milad
  • 163

2 Answers2

7

You have to install the main Expect package by

sudo apt-add-repository universe
sudo apt-get install expect

and it will install tcl-expect as dependency for you.

To run Expect scripts avoiding problems with Anaconda you have to manually specify PATH variable and then run your expect/tcl script:

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
autoexpect ./shell.sh

or in one line:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin autoexpect ./shell.sh

To ease every autoexpect command execution you can add the following alias to the ~/.bashrc:

alias autoexpect='PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin autoexpect'
N0rbert
  • 99,918
0

When using conda, conda's own expect overrides the original expect command, creating a conflict.

Solution:

Reinstall the expect command

conda install -c eumetsat expect

When using unbuffer again, it is back to normal.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Apr 28 '23 at 12:04