Computing.Net > Forums > Linux > Auto Telnet to non-Unix host

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Auto Telnet to non-Unix host

Reply to Message Icon

Name: alanminor
Date: October 18, 2005 at 16:26:21 Pacific
OS: Linux 9
CPU/Ram: Pentium 2Gb
Comment:

I want to automate a regular telnet to a non-Unix hot that accepts a telnet connection. There is some simple dialog to identify a file. Then I would use FTP to download the file. How can I automate the telnet dialog?

AP



Sponsored Link
Ads by Google

Response Number 1
Name: 3Dave
Date: October 19, 2005 at 04:27:08 Pacific
Reply:

You can use expect to interact scripts with programs....or possibly do the whole thing in perl with the Net::Telnet module, eg:

use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,
Errmode=>'die');
$telnet->open('camel.perlfect.com');
$telnet->waitfor('/login: $/i');
$telnet->print('bilbo');
$telnet->waitfor('/password: $/i');
$telnet->print('baggins');
$telnet->waitfor('/\$ $/i');
$telnet->print('who');
$output = $telnet->waitfor('/\$ $/i');
print $output;

or

use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,
Errmode=>'die'
Prompt => '/\$ $/i');
$telnet->open('camel.perlfect.com');
$telnet->login('bilbo', 'baggins');
print $telnet->cmd('who');

You should also be able to run the FTP command from the script too....


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Auto Telnet to non-Unix host

telnet to linux server www.computing.net/answers/linux/telnet-to-linux-server/18760.html

Unable to telnet to RH 7.1 www.computing.net/answers/linux/unable-to-telnet-to-rh-71/5819.html

unable to open display error www.computing.net/answers/linux/unable-to-open-display-error/15556.html