Title: Execute telnet from a script
Author: Sandro Tosi
Last modified: 2005-02-11
You may think that telnet, due to it's an interactive process, could
not be executed in an automatic, not-interactive script. You're
wrong. Actually, it is possible, doing so:
# (sleep 3; echo username; sleep 3; echo password; \
sleep 5; echo "ls -l"; sleep 3; echo "exit") | telnet hostname
The sleep commands are needed to let telnet ``process'' the command
sent.
This creates a security hole as your userid and password for the
remote system are written the script. So the script must only be
readable by the owner. Luckily, the "echo" commands do not appear to
be visible if you do ``ps'', but this may not be true for all Unices.
|