Solved

windows command line pipe "|" not working as expected

Posted on 2008-06-13
4
4,505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

733 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