Solved

windows command line pipe "|" not working as expected

Posted on 2008-06-13
4
4,449 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
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…

707 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

12 Experts available now in Live!

Get 1:1 Help Now