Well I have an issue, a big one. I am trying to develop a script to help me change the passwords for let's say 1000 devices. The thing I have to do is :
1. connect to the device, through ssh - it has a linux interface
2. then change the password for user admin - level
3. enter root level and change the password for user root.
After these three steps, the script must grab a second ip address from the txt file and repeat the process. Well everything is ok untill now. I have the following issues :
a) some of my devices have two ip addresses through which they can be accessed remotely; it's a redundant solution, if one ip responds to ping, the second one doesn't; so the device can be accessed remotely through one of the 2 ip addresses.
Let's say the txt file contains 4 ip addresses IP1, IP2, IP3, IP4. - with IP1 and IP2 coresponding to one device, and IP3 and IP4 corresponding to the second device.
The script goes ok if my txt file had only IP addresses that respond to ping and if my devices had only IP address to connect to them.
Well, in the example with the two devices : Tera term connects to IP1, solves the job, exists the session and then it tries to connect to IP2 which corresponds to the same device.
At this moment, the script should wait for let's say 5 sec, and if the IP address is not accessible to jump to the next IP - as in our example - IP3 - and also to type in a log file a message :
"IP2" is not accessible.
b) the second issue is that if the first IP address in the txt file is an ip address which is not reachable, THE SCRIPT STOPS. It should be done something for the script, to test the reachability to the host (ip address from the txt file) first, type a message in a log file and jump to the next IP address.
Final word : The script works ok if the txt file contains only accesible IP addresses (accessible to ping) !!!
Here is my script :
Code: Select all
- fileopen fh "e:\bytton\bytton_IP.txt" 0
- filereadln fh line
- while result=0
- strconcat line ':2222 /ssh /auth=password /user=admin /passwd=xxxxxxxx'
- connect line
- wait 'admin@bytton:~$'
- sendln 'passwd'
- wait 'Old password:'
- sendln 'xxxxxxx'
- wait 'Enter new password:'
- sendln 'xxxxxxxxxxx'
- wait 'password:'
- sendln 'xxxxxxxxxx'
- filereadln fh line
Thank you in advance, I hope to hear from you soon !!!