Solved

windows command line pipe "|" not working as expected

Posted on 2008-06-13
4
4,468 Views
Last Modified: 2013-11-14
> I have 2 shell windows open (cmd.exe), in one I run netcat as server and in other one netcat as client.

shell 1: time | "c:\Program Files\netcat\nc.exe" -l -p 22

shell 2: "c:\Program Files\netcat\nc.exe" localhost 22
The current time is: 20:00:25,28
Enter the new time:

> So far, everything looks good.
> Now I enter something in shell 2
shell 2: blahblah

> but nothing is displayed in shell 1
> I enter 123 in shell 1
shell 1: 123

> and suddenly I see:
shell 1: 123
shell 1: blahblah

> the blahblah string was waiting somewhere for something to happen, but I have no clue why. You can also try to send larger string or more strings from shell 2, but these will not appear in shell 1, until some text is sent from shell 1. The almost exact scenario (use "date" instead of "time") works on linux as expected.

> So my question is, why is the input from shell 2 not displayed immediately in shell 1?
0
Comment
Question by:ineya
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:fcarrai
ID: 21787725
On shell 1 the "time" command remain waiting for the new time setting.
Could it be this the problem ?
Repeat your test using a nomal "echo 123" command instead of "time".
0
 
LVL 3

Author Comment

by:ineya
ID: 21787740
Yes, this looks like cause, but it is not clear to me, why it is affecting output of netcat. It appears as if the netcat doesn't have access to stdout in that moment. And instead of mixing outputs from 'time' (the output produced by echoing your input) and netcat, windows is somehow switching from one to another under some "specific conditions".
0
 
LVL 3

Assisted Solution

by:fcarrai
fcarrai earned 500 total points
ID: 21787875
In my opinion the reason(s) has to be searched in the pipe implementation mechanisms and in the stdin, stdout redirection. The "mix" you are referring to could be possible only  if the application has independent threads for input and output. This doesn't look to be your case.


0
 
LVL 3

Accepted Solution

by:
ineya earned 0 total points
ID: 21788023
Problem appears to be in windows port of netcat made by Chris Wysopal (also known as Weld Pond).
I tried to get source codes, but they are nowhere to be found, so I can just guess.

I wrote a small utility just to simulate output coming from network
time | my_utility
and it has no problem at all to write to output.

So I tried cygwin netcat and it also works very well. So my guess is there is some limitation (or bug) in windows port.
0

Featured Post

Make managing Office 365 email signatures a breeze

Are you using Office 365? Having trouble trying to set up email signatures for your users? Getting stressed out managing multiple signatures? Need an easier way to manage? We have a solution for you, try the most-user friendly and powerful signature management tool on the market.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

#Citrix #POC #XenDesktop #vCenter #VMware #ESX
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now