Command to execute a command line
Issue
After searching the net looking for my answer, I post here to ask the question:
I'm trying to write a script that will retrieve files automatically config routers on my network. I want it automatically executes what I do by hand.
This is the algorithm:
Connecting telnet 192.168.1.1 Write "login" Wait Write "password" Wait Write "in" Wait Write "enable" Wait Write "copy running-config tftp" Wait Write "192.168.1.2" Wait Write "test" Wait Write "exit"
In bash, it would:
telnet 192.168.1.1 eval "login" sleep 1 eval "password" sleep 1 eval "to" sleep 1 eval "enable" sleep 1 eval "copy running-config tftp" sleep 1 eval "192.168.1.2" sleep 1 eval "test" sleep 1 eval "exit" exit
I scored "eval" command by default, obviously it does not work. Do you know a command to automate this task? I heard about the language but I would expect whether it is possible to do in Bash script initially.
Solution
Normally it is in deposits, a simple apt-get (or aptitude) should suffice -
Edit: On a Ubuntu 8.10:
~ $ Aptitude search expect p empty-expect - Run Processes and Applications Under pseudo-terminal p expect - A program automaton That can interactive applications p expect-dev - A PLC Programs that can interactive applications (Developmen expect-tcl8.3 p - A PLC Programs that can interactive applications p expect-tcl8.3-dev - A PLC Programs that can interactive applications (Developmen p expectk - A PLC Programs that can interactive applications (Tk hooks) p-expectk tk8.3 - A PLC Programs that can interactively applications (Tk hooks) libexpect p-perl - Expect.pm - Perl Expect interface libexpect p-simple-perl - Wrapper around the Expect module p libnet-scp-expect-perl - Wrapper for scp to send passwords via Expect p libtest-expect-perl - Automated driving and testing of terminal-based programs i A python-pexpect - Python module for Automating Interactive Applications v python2.4-pexpect - v python2.5-pexpect
Note
Thanks to jipicy for this tip on the forum.