Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

telnet package

Status
Not open for further replies.

preethib

Programmer
Jul 20, 2000
39
IN
Hi,

I am trying to write a script that simple executes a command on the telnet to a host and port and saves a 'result.txt' in the same directory.
-------------
Example:
-------------
test>telnet test.host.com 9999
Trying ..
Connected to test.host.com
Escape Character '^]'.
<command to execute>
{should output results}
-------------
This works fine showing results when tried to telnet and execute a command. I have a list of commands in a text file I like to execute when connected to a <host & port> on telnet.

Need help as to what packages to use and how. I have never tried this type before, but would appreciate if an expert can help.


balji9
{preethib@yahoo.com}
 
You can find a module that will help at
Net-Telnet-3.02.tar.gz

If you don't want to use the module, you can simply open a pipe to 'telnet', connect to the other system, and print your commands through the pipe. Here is an example of doing that with ftp...

Code:
# Set the default values.
$cmd       = &quot;ftp -n&quot;;  # change &quot;ftp -n&quot; to &quot;cat -n&quot; for testing.

$template  =
&quot;      open $remote_host
       user anonymous guest\@$localhost
       ascii
       lcd \&quot;$config_dir\&quot;
       cd $remote_dir
       get $dblist_file 
       bye
&quot;;
print $template;

# Run the batch ftp command.
print(STDERR &quot;      Running command ($cmd).\n&quot;);
open(CMD, &quot;|$cmd&quot;) || die(&quot;Could not start command ($cmd). $!\n&quot;);
print CMD $template;
close(CMD);

I would suggest figuring out the module. It has been my experience that most available module on CPAN will save a lot of work in the long run.

'hope this helps...




keep the rudder amid ship and beware the odd typo
 
Hi Goboating programmer,

Thanks for the reply. I am a bit confused on using login information. Since when I try to run the command on telnet I don't enter any login/passwd information. As mentioned before, I type in the command just after the line

'Connected to test.host.com
Escape Character '^]'.'

Does this mean by default I am using the same login profile of the system to telnet.



balji9

 
hello balji9,
I'm sorry I don't have time to get into this right now. I did, however, find a decent reference for using the Net::Telnet module on activestate.com at
That module is available for Linux, Solaris, and Windows from or for the WinOS's from activestate using their PPM utility. Sorry I can't be of more use immediately. I have not worked with this module before and don't have the time to do any digging.

'hope this helps.




keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top