1

How to execute the shell scipt?

When I ran my script using:

jalaj@jalaj-SVF14212SNB sudo ./startvpn.sh  
[sudo] password for jalaj: 
sudo: unable to execute ./startvpn.sh: Permission denied //It says

When I execute this using sudo sh startvpn.sh [sudo] password for jalaj:

I get the output as 

startvpn.sh: 2: startvpn.sh: spawn: not found
startvpn.sh: 3: startvpn.sh: expect: not found
startvpn.sh: 4: startvpn.sh: expect: not found
startvpn.sh: 5: startvpn.sh: interact: not found

Below is my script

#!/usr/bin/expect 
spawn openconnect --no-cert-check 103.194.44.2
expect -exact "Username:"send -- "XYX\n"
expect -exact "Password:"send -- "XYX%"
interact

I checked the above permission using

-rwxrw---x 1 jalaj jalaj 168 Aug 10 12:29 startvpn.sh

It say users jalaj can execute but I am not able to execute.
Can anyone guide me how to execute the script?

4
  • You do not need sudo to execute the script. remove it Commented Aug 11, 2017 at 6:10
  • @Jens Then only it says the same output Commented Aug 11, 2017 at 6:15
  • 1
    Do you have expect installed? Commented Aug 11, 2017 at 6:22
  • can you Show your script please? Commented Aug 11, 2017 at 6:36

1 Answer 1

1

You have to ensure expect is actually installed:

Debian-like:

sudo apt-get install expect

RedHat-like:

sudo yum install expect

Then you might want to use sudo to execute your script.


Check this previously asked question as well: "Use expect in bash script to provide password to SSH command"

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.