user1580018
user1580018

Reputation: 3749

Piping commands into a console

I'm trying to pipe Windows commands into a program that essentially runs a console and I'm a newbie at this so I'm not quite getting the command right. What I want to do is pipe the command dir /b > out.txt into that other program.

The command is

echo dir /b > out.txt | nc.exe 127.0.0.1 7003 - ignore the nc.exe its not important

What I want is to pipe the output of echo which should be "dir /b > out.txt" but I'm getting the order of operations or something wrong. Currently what happens is that I write "dir /b" into the file out.txt and pipe nothing into nc.exe.

Upvotes: 0

Views: 658

Answers (2)

Nahuel Fouilleul
Nahuel Fouilleul

Reputation: 19315

double quote or escape >

echo "dir /b > out.txt" | nc.exe 127.0.0.1 7003

or

echo dir /b ^> out.txt | nc.exe 127.0.0.1 7003

Upvotes: 2

jasper
jasper

Reputation: 3474

Not sure if its good enough for you.

echo stackoverflow.com > out.txt
nslookup<out.txt

Take a gander at http://www.robvanderwoude.com/redirection.php

Upvotes: 0

Related Questions