0

I have installed the Nordvpn linux app After using it for some days I have realised I need to login again sometimes.

Login is done by the command and the response is:

root@root:~ $ nordvpn login
Please enter your login details.
Email / Username:        
Password: 

I want to automate this login using a login.sh script. I tried using this:

#!/bin/bash
nordvpn login
expect "Email / Username: "
send "[email protected]"
expect "Password: "
send "password"

I'm getting this output:

couldn't read file "Email / Username: ": no such file or directory
login.sh: 4: login.sh: send: not found
couldn't read file "Password: ": no such file or directory
login.sh: 6: login.sh: send: not found

Update: Changed my login.sh

#!/usr/bin/expect -f
spawn nordvpn login
expect "Email / Username: "
send "example.com\r"
"Password: "
send "password\r"
expect eof

It worked for the first time. I tried logging out and again to login getting this output:

spawn nordvpn login
You are already logged in.
send: spawn id exp4 not open
  while executing

But I am not logged in

1
  • If you are using expect, shouldn't your 1st line be, "#!/usr/bin/expect"? Or wherever your expect is?
    – Glen Yates
    Nov 26, 2019 at 22:37

1 Answer 1

0

This should do it, although I had some issues with sending the password this way.

#!/bin/bash
expect <<END
            spawn nordvpn connect $parameter_country  
            expect "Email / Username"
            send "user_name_here\r"
            expect "Password"
            send "password_here"
            send "\r"
            expect eof
END

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.