?
Solved

windows command line pipe "|" not working as expected

Posted on 2008-06-13
4
Medium Priority
?
4,542 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 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
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). …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

650 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