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:        

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

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

  • 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


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

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

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.