Help!

netcat problem

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Genreal Discussions RSS
Next:  [BUGFIX 1/2] x86, mce, inject: Use real injectm i..  
Author Message
Fabian Lanze
External


Since: Sep 22, 2009
Posts: 1



PostPosted: Tue Sep 22, 2009 4:10 am    Post subject: netcat problem
Archived from groups: alt>os>linux (more info?)

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.

Can someone help me?

Thanks
Back to top
Günther_Wimpassinger
External


Since: Sep 22, 2009
Posts: 1



PostPosted: Tue Sep 22, 2009 5:10 am    Post subject: Re: netcat problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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
Back to top
Pascal Hambourg
External


Since: Oct 11, 2006
Posts: 186



PostPosted: Tue Sep 22, 2009 7:10 am    Post subject: Re: netcat problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hello,

Fabian Lanze a écrit :
>
> echo "cmd1 \n cmd2 \n" | netcat localhost <port>

My echo has interpretation of backslash escapes disabled by default and
it needs -e to enable it.
Back to top
Florian Diesch
External


Since: Mar 11, 2006
Posts: 83



PostPosted: Tue Sep 22, 2009 9:10 am    Post subject: Re: netcat problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Fabian Lanze <fabian_punkt_lanze.DeleteThis@rwth_minus_aachen.de> writes:

> 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>

Did you check that echo does the right thing here? The behaviour of echo
is not standardized when you use backslashes.

Usually it's better to use printf instead of echo if you want to use
backslashes.



Florian
--
<http://www.florian-diesch.de/software/shell-scripts/>
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Genreal Discussions All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum