Accessing data passed by using "pipe" 
Author Message
 Accessing data passed by using "pipe"

Hello,

How do I access data that has been passed to a script using the "pipe"
operator
for e.x:

echo "y" | test.vbs

Regards,

Rohit



Fri, 18 Feb 2005 16:19:19 GMT  
 Accessing data passed by using "pipe"
It doesn't appear to grab anything being piped in.

For example, here's a script that you can use as an alternative answer
to the other question you asked; it will return the command lines for
all processes currently running, including itself.

I saved it as cmlines.vbs, then executed it with the command line

echo y | cscript cmlines.vbs arg1 arg2 arg3

The output it returned for the Commandline of its own process was

cscript cmlines.vbs arg1 arg2 arg3

On Error Resume Next
Dim Wmi, Wql, Process, Processes
Set Wmi = getobject("winmgmts:")
Wql = "select * from Win32_Process"
Set Processes = Wmi.ExecQuery(Wql)
If Processes.Count <> 0 Then
 For Each Process In Processes
  WScript.Echo Process.CommandLine
 Next
End If

--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com


Quote:
> Hello,

> How do I access data that has been passed to a script using the "pipe"
> operator
> for e.x:

> echo "y" | test.vbs

> Regards,

> Rohit



Fri, 18 Feb 2005 17:00:53 GMT  
 Accessing data passed by using "pipe"
Nice piece of code.



Quote:
> It doesn't appear to grab anything being piped in.

> For example, here's a script that you can use as an alternative answer
> to the other question you asked; it will return the command lines for
> all processes currently running, including itself.

> I saved it as cmlines.vbs, then executed it with the command line

> echo y | cscript cmlines.vbs arg1 arg2 arg3

> The output it returned for the Commandline of its own process was

> cscript cmlines.vbs arg1 arg2 arg3

> On Error Resume Next
> Dim Wmi, Wql, Process, Processes
> Set Wmi = getobject("winmgmts:")
> Wql = "select * from Win32_Process"
> Set Processes = Wmi.ExecQuery(Wql)
> If Processes.Count <> 0 Then
>  For Each Process In Processes
>   WScript.Echo Process.CommandLine
>  Next
> End If

> --
> Please respond in the newsgroup so everyone may benefit.
> http://dev.remotenetworktechnology.com



> > Hello,

> > How do I access data that has been passed to a script using the "pipe"
> > operator
> > for e.x:

> > echo "y" | test.vbs

> > Regards,

> > Rohit



Fri, 18 Feb 2005 17:22:31 GMT  
 Accessing data passed by using "pipe"

Quote:
> It doesn't appear to grab anything being piped in.

It does, you're just looking in the wrong place (and/or using the wrong
mindset). ;-)

The point of a pipe is to take the contents of one process' stdout
stream, and pass it into another's stdin stream. It doesn't appear in the
latter's command line, because it's not part of the command line.

Place

  Msgbox WScript.StdIn.ReadAll

in a .vbs file, and then

  echo foo | cscript bar.vbs

Adam
--
Q:      How many surrealists does it take to change a light bulb?
A:      Two, one to hold the giraffe, and the other to fill the bathtub
        with brightly colored machine tools.



Fri, 18 Feb 2005 17:51:27 GMT  
 Accessing data passed by using "pipe"
Ignoring.

Towers of Hanoi.



Quote:

> > It doesn't appear to grab anything being piped in.

> It does, you're just looking in the wrong place (and/or using the wrong
> mindset). ;-)

> The point of a pipe is to take the contents of one process' stdout
> stream, and pass it into another's stdin stream. It doesn't appear in the
> latter's command line, because it's not part of the command line.

> Place

>   Msgbox WScript.StdIn.ReadAll

> in a .vbs file, and then

>   echo foo | cscript bar.vbs

> Adam
> --
> Q:      How many surrealists does it take to change a light bulb?
> A:      Two, one to hold the giraffe, and the other to fill the bathtub
>         with brightly colored machine tools.



Fri, 18 Feb 2005 17:57:29 GMT  
 Accessing data passed by using "pipe"
On the lighter side :

Powell losing war lust.

Said not to extend his term.

British said to rebell.


Quote:
> Ignoring.

> Towers of Hanoi.




> > > It doesn't appear to grab anything being piped in.

> > It does, you're just looking in the wrong place (and/or using the wrong
> > mindset). ;-)

> > The point of a pipe is to take the contents of one process' stdout
> > stream, and pass it into another's stdin stream. It doesn't appear in
the
> > latter's command line, because it's not part of the command line.

> > Place

> >   Msgbox WScript.StdIn.ReadAll

> > in a .vbs file, and then

> >   echo foo | cscript bar.vbs

> > Adam
> > --
> > Q:      How many surrealists does it take to change a light bulb?
> > A:      Two, one to hold the giraffe, and the other to fill the bathtub
> >         with brightly colored machine tools.



Fri, 18 Feb 2005 18:15:08 GMT  
 Accessing data passed by using "pipe"

Quote:

> Ignoring.

> Towers of Hanoi.

Pardon? Was there a vageuly sensible post hiding somewhere in there,
trying desperately to get out?
--
MSDOS is not dead, it just smells that way.
                -- Henry Spencer


Fri, 18 Feb 2005 18:28:35 GMT  
 Accessing data passed by using "pipe"
Yes... he was being surreal.   See your prior post's sig. <g>

Interesting - the StdIn approach  is what I was missing!

--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com



Quote:

> > Ignoring.

> > Towers of Hanoi.

> Pardon? Was there a vageuly sensible post hiding somewhere in there,
> trying desperately to get out?
> --
> MSDOS is not dead, it just smells that way.
>                 -- Henry Spencer



Fri, 18 Feb 2005 19:31:01 GMT  
 Accessing data passed by using "pipe"

Quote:
> Yes... he was being surreal.   See your prior post's sig. <g>

Fairy snuff. Bizarre posts do seem to be something of a habit of his...

Quote:
> Interesting - the StdIn approach  is what I was missing!

You obviously haven't spent enough time writing console utilities :)

Adam
--
"... the average HTML-poster has the IQ of a glass of water ..."
               -- Brandon Hume posting in hfx.general, September 21, 2000



Fri, 18 Feb 2005 20:34:29 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Using extension instead of "type" data

2. Darn pipes "|"

3. Access to "Special Folders" using VBScript

4. "Access denied" when accessing script object

5. pipe Stdout of cmd"dir" to Stdin of vbsript"mytest.vbs"?

6. "Access denied" error when accessing "location.search" with IE6

7. Passing "strings" to a function

8. "Splitting" data

9. how to pass "" to command line

10. Passing "Sub" as parameters

11. LJ postscript message "processing data"??

12. enctype="multipart/form-data"

 

 
Powered by phpBB® Forum Software