Expect Script - String with special characters

Asked

Viewed 105 times

0

I’m building a connection script using expect, spawn, send, etc.

My problem is time to enter the password.

The password I’m testing is test! Q@W#E$R, the problem that when I run it returns:

can't read "R": no such variable
    while executing
"send "teste!Q@W#E$R""

I mean, he’s giving away right at the end, in the $R.

Does anyone know how I make him ignore the function of $ and consider it as part of the string?


Follows the script:

#!/usr/bin/expect -f
spawn /opt/forticlient-sslvpn/64bit/forticlientsslvpn_cli --server <IP>:<PORTA> --vpnuser <USER>
expect "Password for VPN:"
send $'teste!Q@W#E$R'
expect "*(Y/N)"
send "Y\r"
interact
  • I think the system is interpreting the $, tries to use like this send 'teste!Q@W#E$R', with '' instead of ""

  • Hi Denis, thank you for your attention. But I tested it here and it didn’t work either

  • That’s what you’re looking for? send $'teste!Q@W#E$R'

  • Hi Ronaldo, good afternoon, thanks for answering.. but it hasn’t worked out yet can’t read "R": no such variable while executing "send $'test! Q@W#E$R'"

  • It’s shell script you’re using, right?

  • I sent the script in the comment below

  • Tried to send 'teste!Q@W#E$R' ? Without the $

  • The script works, I tested with another user and password and was good

  • yes, I also tested without the ' and the same

  • i also saw that the same error occurs for passwords with *(asterisk)

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.