Reputation:
I am trying to see if I can move to xdotool
from an expect
script.
I use and expect
script with this spawn command
ssh root@IP_ADDRESS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
it waits for:
expect "$login@$addr\'s password:"
in other words it's a very simple script that lets you login to the server via ssh
without having to enter a password. But beyond this expect
is unable to do things in a "precise" manner, I've seen it sending wrong commands repeatedly and it seems unreliable for more than simple tasks.
I was wondering if perhaps xdotool
could do a better job. If xdotool
could somehow listen to the strings on the terminal for example
and wait for:
"$login@$addr\'s password:"
Can this be done ?
The only method I can think of right now is adding sleep
or something of that nature to my script to make it wait for the login, which could fail.
Upvotes: 1
Views: 531
Reputation: 6388
As much as I love xdotool
and pretty much all of Jordan Sissel's scripts, config files, hacks, and applications (++ Jordan!) I don't think xdotool
is what you are looking for here. As for expect
there are tcl
, python
and perl
variants and the logic of your script can be as sophisticated and robust as those languages allow.
I'd revisit the script and try to make it handle possible errors and login prompt changes more correctly. The second thing I would do is not allow root login with ssh
(actually that would be the first thing I would do). If you are using SSH you have the full power of SSH configuration files, Public Key Encryption, Kerberos, LDAP, and other approaches to making logins convenient, secure, and easily manageable from a security policy and systems administration perspective.
Do all that and then think of how you could use xdotool
- because xdotool
rocks!
ps: check the ssh_config
manual page: there are many secure and convenient configuration options for what you are trying to achieve here.
Upvotes: 2