flush telnet input

flush telnet input

Post by Scot » Wed, 20 Jul 2005 13:14:49



Hi all,

I wish to send a simple command via telnet such as:

echo "my_command arg1 arg2"  | telnet host port

but I'm finding that my program running on $host:$port
doesn't actually receive the command. (It only accept()s &
close()s the connection.)

I can solve my problem with a delay:

(echo "my_command arg1 arg2" && sleep 1) | telnet host port

However I don't really want to do that as sometimes I have
multiple commands to send (& the time it takes to finish varies)
& it is useful to me that control returns to my shell ASAP.

I suspect that the telnet program is receiving a SIGPIPE
before it is able to actually send out the commands.

So, my question is:

How can I get telnet to flush the commands before it closes
the connection & returns control to my shell?

Any info/pointers muchly appreciated.

SCoTT. :)

 
 
 

flush telnet input

Post by John » Wed, 20 Jul 2005 15:28:31



> Hi all,

> I wish to send a simple command via telnet such as:

> echo "my_command arg1 arg2"  | telnet host port

> but I'm finding that my program running on $host:$port
> doesn't actually receive the command. (It only accept()s &
> close()s the connection.)

> I can solve my problem with a delay:

> (echo "my_command arg1 arg2" && sleep 1) | telnet host port

> However I don't really want to do that as sometimes I have
> multiple commands to send (& the time it takes to finish varies)
> & it is useful to me that control returns to my shell ASAP.

> I suspect that the telnet program is receiving a SIGPIPE
> before it is able to actually send out the commands.

> So, my question is:

> How can I get telnet to flush the commands before it closes
> the connection & returns control to my shell?

> Any info/pointers muchly appreciated.

Are you using telnet in line rather than character mode?

--
John.

 
 
 

flush telnet input

Post by Scot » Wed, 20 Jul 2005 15:42:24


Quote:> Are you using telnet in line rather than character mode?

echo "^]mode line\nhello" | telnet echidna 3141

where ^] is the telnet escape character CTRL-]

doesn't work if that's what you mean.

SCoTT. :)

 
 
 

flush telnet input

Post by Michael Heimin » Wed, 20 Jul 2005 15:59:04



Quote:> Hi all,
> I wish to send a simple command via telnet such as:
> echo "my_command arg1 arg2"  | telnet host port

[..]

Quote:> How can I get telnet to flush the commands before it closes
> the connection & returns control to my shell?

I'd use ssh instead of telnet if possible, check out 'expect' if
not.

Good luck

--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)

#bofh excuse 349: Stray Alpha Particles from memory packaging
caused Hard Memory Error on Server.

 
 
 

flush telnet input

Post by nasi » Thu, 21 Jul 2005 06:13:09


I would also prefer to use SSH where you can run a command
non-interactively e.g.
server1:$> ssh server2 "uname -a; pwd; ls -la"

Or, use perl in which you will have to download and add Net-Telnet
module.

- nasir



> > Hi all,

> > I wish to send a simple command via telnet such as:

> > echo "my_command arg1 arg2"  | telnet host port

> [..]

> > How can I get telnet to flush the commands before it closes
> > the connection & returns control to my shell?

> I'd use ssh instead of telnet if possible, check out 'expect' if
> not.

> Good luck

> --
> Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)

> #bofh excuse 349: Stray Alpha Particles from memory packaging
> caused Hard Memory Error on Server.

 
 
 

flush telnet input

Post by John DuBo » Fri, 22 Jul 2005 04:26:19




>Hi all,

>I wish to send a simple command via telnet such as:

>echo "my_command arg1 arg2"  | telnet host port

>but I'm finding that my program running on $host:$port
>doesn't actually receive the command. (It only accept()s &
>close()s the connection.)

>I can solve my problem with a delay:

>(echo "my_command arg1 arg2" && sleep 1) | telnet host port

>However I don't really want to do that as sometimes I have
>multiple commands to send (& the time it takes to finish varies)
>& it is useful to me that control returns to my shell ASAP.

>I suspect that the telnet program is receiving a SIGPIPE
>before it is able to actually send out the commands.

Close, but SIGPIPE is sent to the writer, not the reader.  telnet is
getting EOF before it's gotten around to sending the command, and so
proceeds to shut things down without having ever sent it.

Quote:>So, my question is:

>How can I get telnet to flush the commands before it closes
>the connection & returns control to my shell?

Use a utility that's designed for this sort of thing, like socat or netcat.

        John
--

 
 
 

1. How do I flush keyboard inputs?

Hi, I'm writing a small program using Curses functions,
now I have this problem that when I'm reading the keyboard
(key = wgetch(window)) and pressing KEY_LEFT it interprets
it as a LOCAL_ESCAPE_KEY and leaves a "d" on the
input queue. So the next time I read the input queue the first
character I read is a "d".

To get around this I need to flush the input queue but I do not
know how to do that.
Could someone please help me with this.

/Michael

2. KDM gives only xterm in left uperhand corner when logged in

3. flushing the input buffer in ksh

4. Harware config. 2 DD IDE & EIDE

5. IOCTL flushing input buffer queues

6. pppd and stderr

7. flushing input prior to a read

8. opinions on Turbo Linux?

9. HOWTO: flush inputs in Curses

10. Flushing input prior to a read

11. flushing output/input

12. Can a PIPE input be FLUSHED?

13. strange input line retype problem with bash during telnet