Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my expect script failing on line 1? [closed]

Tags:

bash

expect

bin

The very first line of my expect script fails. Here are the entire contents of my script and it fails:

#!/usr/bin/expect -f

And it fails right off the bat with

": no such file or directory

as my response. Expect is in fact installed and is located in /usr/bin/ and I am running this from root. I have no extra spaces or lines before the # sign either. Of course there was more to the script originally but it fails way before it gets to the good stuff.

like image 811
Dennis Day Avatar asked Dec 22 '10 02:12

Dennis Day


2 Answers

Tried it and here is the result: /usr/bin/expect^M: bad interpreter

Is it possible that there's a Windows newline (the ^M) in there that's confusing the script? You can try od to see what newline character(s) is after the expect and tofromdos or an editor (e.g. emacs in hexl-mode) to remove it. See the man pages for more info.

like image 195
Bert F Avatar answered Nov 10 '22 07:11

Bert F


I had this issue and found I didn't have the expect interpreter installed! Oddly enough, if you ran the command in the shell it worked. However, through a shell script I got this error:

/usr/bin/expect: bad interpreter: No such file or directory

I fixed it by simply installing the Expect interpreter. The package name that was chosen was: expect libtcl8.6

Just run:

sudo apt-get install expect
like image 23
G_Style Avatar answered Nov 10 '22 09:11

G_Style