Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - getting arguments from pipe

Reply
 
Old 11-22-2007   #1 (permalink)
luntain


 
 

getting arguments from pipe

Why my program is not getting arguments from the pipe?

When I invoke it like this:
ls | ./myprog.exe

The arguments passed to my program are empty.

My System SpecsSystem Spec
Old 11-22-2007   #2 (permalink)
Marco Shaw [MVP]


 
 

Re: getting arguments from pipe

luntain wrote:
Quote:

> Why my program is not getting arguments from the pipe?
>
> When I invoke it like this:
> ls | ./myprog.exe
>
> The arguments passed to my program are empty.
myprog.exe is not a PowerShell cmdlet or script, therefore it would not
understand .NET objects that are being passed to it via the pipeline.

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 11-22-2007   #3 (permalink)
Shay Levi


 
 

Re: getting arguments from pipe

Marco,

I'm not sure this is the case. This works fine on cmd.exe but returns error
in PowerShell:

PS > ipconfig /all | find /i "ip"
FIND: Parameter format not correct

I tried to "strip" the objects from get-childitem to force strings on the
pipe, it doesn't wotk either

PS > get-childitem | foreach {$_.name} | find /i "ps1"
FIND: Parameter format not correct

PS > get-childitem | out-string | find /i ".ps1"
FIND: Parameter format not correct



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com


Quote:

> luntain wrote:
>
Quote:

>> Why my program is not getting arguments from the pipe?
>>
>> When I invoke it like this:
>> ls | ./myprog.exe
>> The arguments passed to my program are empty.
>>
> myprog.exe is not a PowerShell cmdlet or script, therefore it would
> not understand .NET objects that are being passed to it via the
> pipeline.
>
> Marco
>
> PowerGadgets MVP
> http://www.powergadgets.com/mvp
> Blog:
> http://marcoshaw.blogspot.com

My System SpecsSystem Spec
Old 11-22-2007   #4 (permalink)
Marco Shaw [MVP]


 
 

Re: getting arguments from pipe

Shay Levi wrote:
Quote:

> Marco,
>
> I'm not sure this is the case. This works fine on cmd.exe but returns
> error in PowerShell:
>
> PS > ipconfig /all | find /i "ip"
> FIND: Parameter format not correct
This will work:
ipconfig /all | find /i `"ip`"

OK, perhaps we need to understand what myprog.exe actually does and
whether it works from DOS when doing something like a regular 'dir'.

Marco
My System SpecsSystem Spec
Old 11-22-2007   #5 (permalink)
Shay Levi


 
 

Re: getting arguments from pipe

Thanks, figured out that I needed to preserve the quote for find.exe, this
will work too:

ipconfig /all | find /i """ip"""



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com


Quote:

> Shay Levi wrote:
>
Quote:

>> Marco,
>>
>> I'm not sure this is the case. This works fine on cmd.exe but returns
>> error in PowerShell:
>>
>> PS > ipconfig /all | find /i "ip"
>> FIND: Parameter format not correct
> This will work:
> ipconfig /all | find /i `"ip`"
> OK, perhaps we need to understand what myprog.exe actually does and
> whether it works from DOS when doing something like a regular 'dir'.
>
> Marco
>

My System SpecsSystem Spec
Old 11-22-2007   #6 (permalink)
Keith Hill [MVP]


 
 

Re: getting arguments from pipe

"luntain" <kamil.dworakowski@xxxxxx> wrote in message
news:84bd09e6-f3ae-45f6-957c-ed0654f448c4@xxxxxx
Quote:

> Why my program is not getting arguments from the pipe?
>
> When I invoke it like this:
> ls | ./myprog.exe
>
> The arguments passed to my program are empty.
I think you mean stdin since you haven't specified any arguments to
myprog.exe. Does your myprog.exe read from stdin?

--
Keith

My System SpecsSystem Spec
Old 11-23-2007   #7 (permalink)
Flowering Weeds


 
 

Re: getting arguments from pipe


"Marco Shaw [MVP]"
Quote:
Quote:

>> ls | ./myprog.exe
Quote:
Quote:

>> The arguments passed to my
>> program are empty.
Quote:

>
> myprog.exe is not a PowerShell cmdlet
> or script, therefore it would not understand
> .NET objects that are being passed to it
> via the pipeline.
>
Perhaps Microsoft's data parser,
Log Parser 2.2, "understand .NET
objects that are being passed to it
via the pipeline".

Either e-book or paperback book.
Syngress Publishing - Microsoft Log Parser Toolkit
http://www.syngress.com/catalog/?pid=3110

The below is one long line on
the PowerShell command line.

PS> ls | LogParser.exe "SELECT Field6
AS FileName FROM STDIN
WHERE Field6 LIKE '%.ps1' " -i:tsv
-headerRowff -nSkipLines:8 -nFields:6
-iSeparator:"spaces" -statsff
FileName
----------------
aTestScript1.ps1
PS>

Mmm it seems Log Parser "understands"!
Quote:

> whether it works from DOS
DOS?????

Logparser Forums
http://forums.iis.net/default.aspx?GroupID=51

Skip through the forums and write one's
data parsing once into a Log Parser text
query file (that uses params), that can be
called by almost any Windows language!

Just another "command line shell" way!



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Using pipe in Powershell PowerShell
Pipe response Yes to ALl PowerShell
Pipe a pipe command to a file VB Script
possibly pipe max? PowerShell
Getting arguments from STDIN when command line arguments are missing PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46