Why is my pending script not working on line 1?

The very first line of my wait script fails. Here is the entire contents of my script, and it fails:

#!/usr/bin/expect -f 

And he fails from the start with

 ": no such file or directory 

as my answer. Expect is actually installed and located in / usr / bin /, and I run it from root. I have no extra spaces or lines before the # sign. Of course, there was more for the script initially, but it didn’t go the way before it hit the good stuff.

+7
source share
4 answers

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

Is it possible that there is a new Windows line ("^ M") that confuses the script? You can try "od" to see the newlines after "expect" and "tofromdos" or an editor (like emacs in hexl-mode) to remove it. See the manual pages for more information.

+12
source

Your line endings are incorrect. Move it through dos2unix or tr -d '\r' .

+7
source

I had this problem and I found that I did not have the interpreter of expectations installed! Oddly enough, if you ran the command in the shell, it worked. However, through the shell script I received the error: / usr / bin / expect: bad interpreter: There is no such file or directory.

I fixed it by simply installing the Expect interpreter. Package Name Selected: expect libtcl8.6

Just run: sudo apt-get install wait

+3
source

I really don’t know, we expect, to be honest, but when I run this on my system, it “works” perfectly. Nothing happens, but this is what I expect. I am not getting an error message. According to the manual page,

 #!/usr/bin/expect -f 

is the correct way to run a script. Expect then break out on the script that you are executing as cmd file.

The way I got this to reproduce the problem was to actually put ^ M at the end of the line instead of the usual new line (saw Bert F's answer, and this prompted me to try). I am sure that the vim: set list command will show any odd characters.

+1
source

All Articles