I am new in bash scripting. In my work, I provide support to several users and when I connect to their computers I use the same admin and password, so I am trying to create a script that will only ask me for the IP address and then connect to the computer without having me to type the user and password.
Here's the script:
read -p "Enter ip address: " IP_ADDRESS
pss="123@456"
open vnc://test:$pss@$IP_ADDRESS
If I remove the @ from my password I am able to connect with no issue. I have tried to escape the @ by adding a backslash before the character but still not working (e.g. 123\@456 ). Do you guys have any suggestions?..
Just a suspicion: as @ is the separator between user info and target IP, it is inapt to be used inside the password. Are you dependent on it? Just remove it and try again.
Thanks for your reply, RudiC. The script works fine if the password does not contain the "@". The thing is that we have over 3,000 computers using a password with "@" for the admin account. Also, I would need to make a request to a different department that manages the computer images.. so it wouldn't be that simple to change the password :(...
It is working now :).. I replaced the "@" by %40 and I am able to connect with no problem.. I'm using this script to remote control Mac computers without typing the user and pass every time I need to connect to a computer. Thank you so much. This is going to be very useful for me. I really appreciate your help.