Fabian Lanze schrieb:
> Hi!
>
> I have a problem using netcat. I have a process I can connect to via a
> certain port. This Process can receive severeal commands. When I use
> telnet or netcat to connect like
>
> netcat localhost <port>
>
> i can send commands like
>
> cmd1 <enter>
> cmd2 <enter>
>
> - everything works fine. But I want to send a series of commands to the
> process with a single netcat command:
>
> echo "cmd1 \n cmd2 \n" | netcat localhost <port>
>
> and this does not work. Only cmd1 is performed (the authentification)
> and nothing else. What am I doing wrong? I tried -i 2 but it didn't help.
>
If you pass the commands by hand (via telnet, ...) your application get
more and smaller packets. So it can rebuild your input command by
command. If you pass more commands at once, you application recieve only
data packet with both commands included. You may use "\n" as your
command delimiter and you have to process the recieved data character by
character until the end or a delimiter.
It is possible that one command is sent with more than one packet.
I hope my crystal ball works.
Guenther
Apologise my english