On 2016-12-02 16:59, Mark Goldstein wrote:
On Fri, Dec 2, 2016 at 5:36 PM, Per Jessen <per@computer.org> wrote:
I think I know what you mean, was it called "ex<something>" ? "screen" might be another alternative, but I still think netcat will do it:
I still have to pass the login and password interactively to telnet.
It was "expect". Used Tk, IIRC. There is Perl modification Perl::Expect. I used it once to automate some test - create telnet sessions, controlled by scripts. It was not trivial to use, but worked nicely. There is similar functionality in Python built in (do not remember by heart, but can find out, if needed
Thanks! Yes, that was it, expect. And "autoexpect" to generate the initial script: cer@Isengard:~> autoexpect telnet router.valinor autoexpect started, file is script.exp Trying 192.168.1.1... Connected to router.valinor. Escape character is '^]'. BCM963268 Broadband Router Login: **** Password:
wan show VCC Con. Service Interface Proto. IGMP NAT MLD Status IP ID Name Name address N/A 2 3 eth0.2 IPoE Disable Enable Disable Connected 10.*.*.* N/A 3 2 eth0.3 IPoE Enable Enable Disable Connected 10.*.*.* N/A 1 6 ppp0.1 PPPoE Disable Enable Disable Connected 83.Z.Y.X quit
Bye bye. Have a nice day!!! Connection closed by foreign host. autoexpect done, file is script.exp cer@Isengard:~> So, I already have "script.exp" done. [...] Finally, this does it: #!/bin/bash ~/bin/GetIpFromRouter.exp > ~/bin/router_output.log grep PPPoE router_output.log | awk '{ print $10}' -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)