Operating System - Linux
1822349 Members
4634 Online
109642 Solutions
New Discussion юеВ

PIPE something into TELNET on Linux

 
SOLVED
Go to solution
Volker Borowski
Honored Contributor

PIPE something into TELNET on Linux

Hi,
I have a nice Script to backup my Cisco-Router-Configs to a tftp-Server running on HP-UX.
The script works like this:
- Setup a complete string-sequence to do the entire job
- Echo $BACK | telnet cisco-router
This works fine on HP-UX 10.20 and 11.00

Now I wanted to switch this backup to run on a Linux box, and it appears, that the Linux telnet is not accepting anything which is piped inside.
Runing the telnet manually and clipping the entire sequence into the terminal session works as well.
How do I disable Linux Telnet to flush the initial Input ?
I already tried to set up telnet options:
unset autoflush
mode character
Did not help :-(

Running RedHat 6.1 Blue Sky (SAP) Edition?

Thanks in advance
Volker
14 REPLIES 14
Albert E. Whale, CISSP
Honored Contributor

Re: PIPE something into TELNET on Linux

I guess that I would have a different approach. Might I suggest that you launch the command stream on the remote node?

I guess I do not see the point in getting the script from the telnet session on Linux, especially when Linux is extremely capable of storing and/or scheduling it's own processes.

Hope that helps.
Sr. Systems Consultant @ ABS Computer Technology, Inc. http://www.abs-comptech.com/aewhale.html & http://www.ancegroup.com
Mike McKinlay
Honored Contributor

Re: PIPE something into TELNET on Linux

Perl's NET::Telnet and NET::Telnet::CISCO modules may have what you're looking for. Check www.cpan.org.
"Hope springs eternal."
Volker Borowski
Honored Contributor

Re: PIPE something into TELNET on Linux

Thanks Albert,
that is really the thing one should do in general. But I guess it will not work in this case, as the cisco (IOS) router is (as far as I know) not able to execute a scheduled script (Any input on this is welcome). So there is little chance to change the procedure.
Best Regards
Volker
Volker Borowski
Honored Contributor

Re: PIPE something into TELNET on Linux

Hello Mike,
could you please be a little bit more specific. Can I get a diffrent telnet there, which is capable of what I need, or an extension to my ciscos IOS, which can schedule the backupscript ?
Best Regards
Volker
Albert E. Whale, CISSP
Honored Contributor

Re: PIPE something into TELNET on Linux

Volker,

Couldn't you poll the Cisco Router Remotely to extract the configuration? Doesn't Cisco support the ftp command? You should be able to lock down the command from the Console to enable it.

I am certain that there is a solution to this, as Cisco has supplied a Tool which will download the current configuration for any device which has the passwords. You got those, right?

Thanks for the points! We'll get this ironed out for you, one way or another.

Talk to you soon.
Sr. Systems Consultant @ ABS Computer Technology, Inc. http://www.abs-comptech.com/aewhale.html & http://www.ancegroup.com
Mike McKinlay
Honored Contributor

Re: PIPE something into TELNET on Linux

The Perl modules will allow you to use perl to script a telnet process and capture the data you receive during the telnet. In essense, this is a different "telnet" process running within the perl script.
"Hope springs eternal."
Mike McKinlay
Honored Contributor
Solution

Re: PIPE something into TELNET on Linux

Another option: using SNMP to get the config. This came in from the OVFORUM this morning:

"There are a few scripts on the OVFI FTP site: ftp.ovforum.org that will
get the router config via SNMP. I believe they are ciscocfg and cswcmd."
"Hope springs eternal."
Volker Borowski
Honored Contributor

Re: PIPE something into TELNET on Linux

Hello Mike,
that sounds good, although I am no Perl expert. I'll delay this approach until the simple solution will not do it's job. But it might be a way....
May be I can use this diffrent telnet without Perl, as I have everything ready and working, except that Linux Telnet is flushing the input:-(
Thank's a lot.

Hello Albert,
I am on ciscos for quite a while now, and the only way I found out until now, is to login to the router (console or telnet), and issue the "copy config tftp" command, which prompts you for the target server and filename.
I found no way to login to the Router with a ftp client, as the Router provides no FTP daemon or service (that would be a nice thing).
Anyway, I have a working solution on HPUX, which does not work on Linux because of telnet's behavior. So my first approach is to make linux telnet work like the one on HPUX.
If this does not work, I would try to use a diffrent telnet, and if this does not work, i would consider a structural change.

BTW, unless the number of routers you have to work with is equal to one, and the frequency of changes to this router is one per quarter
-> Forget about this config tool.

Best regards
Volker
Volker Borowski
Honored Contributor

Re: PIPE something into TELNET on Linux

Another good shot Mike,
I never tried this SNMP stuff on this, but this sounds quite good. I'll wait with point assignments, until I know the value of this answer a little bit better :-)

Best Regards
Volker
Volker Borowski
Honored Contributor

Re: PIPE something into TELNET on Linux

Hello Mike,
although I am too weak on perl and snmp, I am pretty sure, that your solution will do it's job. I'll reconsider it at next years beginning, and I think i have to do some adjustments for native SNMP stuff to this OV tools.

Anyway, I'll assign points for tax reasons this year ;-)

Keep this message on notify, if you like to hear later, how it turned out.
Thanks again
Volker
Ashish Palkhiwala
Occasional Advisor

Re: PIPE something into TELNET on Linux

Hi Volker,

I have a perl script on HP-UX 10.20,which is supposed to do the same job. but for some reason I am getting following error when running " copy run tftp" cmd.

TFTP:error code 2 received - Access violation.
%Error opening tftp://IPaddressof tftp_server/file name (undefined error).

What should I do to make sure tftp server is running properly. This script used to work fine.

I started getting this error after I rebooted my tftp server. I have tftpd running with tftp user defined in /etc/passwd. and home dir for the user.
I have attached my perl script here please help me.

Thanks
Ashish
Stuart Browne
Honored Contributor

Re: PIPE something into TELNET on Linux

.. just for the record, the telnet client under Linux doesn't mind taking information on the STDIN... However, it doesn't continue running when there isn't any further information on the STDIN..

Simply put, if you throw a few 'sleep 3' (or whatever's) in the appropraite places, you should get it to work.

It isn't terribly stable, and using the TCL based 'expect' is probably better as a simple solution.
One long-haired git at your service...
Volker Borowski
Honored Contributor

Re: PIPE something into TELNET on Linux

Case closed !

Please take a look at the initial posting date!
Did not find or figured out a reasonable solution, but do not need any anymore.
But I am pretty sure that the given answers will lead to a solution.
No more points to win in this thread.

Volker
Stuart Browne
Honored Contributor

Re: PIPE something into TELNET on Linux

*sigh* Yes, I know it's an old post, and I wasn't trying to points-grab..

I was just trying to fill in a blank as to why what you were trying wasn't working for when someone else comes along and has the same query.
One long-haired git at your service...