[nzlug] How to run scipts in telnet?
Michael Field
michael.field at concepts.co.nz
Thu Feb 28 17:17:52 NZDT 2008
Hi Raimund,
Timing... it is all in the timing... If the process feeding the data
into the telnet session dies before the session has finished its work
the program will be 'hung up' (sent UNIX signal 1, most likely killing
the job
Try this:
#!/bin/bash
(
sleep 1
echo username
sleep 1
echo password
sleep 3
echo 'echo "Hi, I want to run this command"'
sleep 10
echo 'exit'
sleep 2
) | telnet localhost
If the process is important, just make the sleep times longer than you
could ever conceive that the remote end will take to answer - and even
then grep the output for some indication of success...
Mike
-----Original Message-----
From: nzlug-bounces at linux.net.nz [mailto:nzlug-bounces at linux.net.nz] On
Behalf Of Raimund Eimann
Sent: Monday, 25 February 2008 12:20 p.m.
To: NZLUG List
Subject: [nzlug] How to run scipts in telnet?
Hi,
I've got an application that can be accessed via telnet (not a shell). I
would
like to send some commands (on a regular basis) to that application
through
the telnet interface. Is there a way to process scripts with telnet?
I've already tried
telnet thehost 2345 < mycommandscript.txt
but that does not seem to work.
There doesn't seem to be a command-line option for this either, at least
I
didn't find anything promising in the telnet man page.
Cheers,
Raimund
_______________________________________________
NZLUG mailing list NZLUG at linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Computer Concepts Limited
25 Leslie Hills Drive
PO Box 8744 Riccarton
Christchurch, New Zealand
Phone: +64-3-348-2500
Fax: +64-3-343-7569
Notice of confidential information:
The information contained in this e-mail message is
confidential information and may also be legally privileged,
intended only for the individual or entity named above.
If you are not the intended recipient you are hereby
notified that any use, review, dissemination, distribution
or copying of this document is strictly prohibited.
If you have received this document in error, please
immediately notify the sender by telephone and destroy the
message. Thank you.
All prices quoted in this email are exclusive of GST & Freight and
valid only while stocks last.
More information about the NZLUG
mailing list