Page 1 of 1 1
Topic Options
#161340 - 2006-04-27 11:51 PM Help with WSHPIPE()... I think. =P
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
I'm using a tool called 'psgetsid' which automagically grabs all of my computers SIDs across my domain. I'm getting some errors on some of my machines and I'd like to investigate furuther but a simple redirect (>) doesn't log the error information for some reason. Because of this, I wanted to run the utility through WSHPIPE() to write each line out into a CSV file so I can look at the results at my leisure. The following command line generates SIDs for all computers across my domain:
Code:
c:\>psgetsid \\*



This works fine and shows the result for my computer:
Code:
	$rc = WshPipe("%COMSPEC% /c c:\psgetsid.exe ")
For Each $line in $rc
? $line
'test'
sleep 1
Next



I want to be able to use the original command line with the "\\*" so that it will generate output for all computers across my domain but throwing that string into WSHPIPE() with %COMSPEC% doesn't seem to work; my script just hangs with the "\\*" in it. So I tried this and get the same thing. Something I'm missing about interpolation???

Code:
	$rc = WshPipe("%COMSPEC% /c c:\psgetsid.exe "+CHR(92)+CHR(92)+CHR(42))
For Each $line in $rc
? $line
'test'
sleep 1
Next


Top
#161341 - 2006-04-28 08:00 AM Re: Help with WSHPIPE()... I think. =P
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
You could use the old DOS Trick of re-directing your output to a text file..

* New File: c:\psgetsid.exe > c:\file
* Append to a file: c:\psgetsid.exe >> c:\file

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#161342 - 2006-04-28 08:14 AM Re: Help with WSHPIPE()... I think. =P
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Morning!

Just a question, when I read the udf it states -
;Parameters:
; COMMAND : REQUIRED. String value indicating the command line used to run the script.
; The command line should appear exactly as it would if you typed
; it at the command prompt.
;

, shouldn't you just be able to go WshPipe("%COMSPEC% /c c:\psgetsid.exe \\*") ?
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#161343 - 2006-04-28 06:57 PM Re: Help with WSHPIPE()... I think. =P
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
well yes that's what I thought which is why I was looking for a little clarification that I was calling the string correctly.
Top
#161344 - 2006-04-28 08:06 PM Re: Help with WSHPIPE()... I think. =P
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
And sorry kdyer, I don't know why but I didn't see your post... I tried that originally:
Quote:

..furuther but a simple redirect (>) doesn't log the error information for some reason



I tried the simple redirect to start out with and it writes the success to the output file but not the error information. This is why I wanted to use KiX and WSHPIPE.

Top
#161345 - 2006-04-28 08:11 PM Re: Help with WSHPIPE()... I think. =P
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

I tried the simple redirect to start out with and it writes the success to the output file but not the error information



You cannot expect both unless you explicity redirect both STDOUT and STDERR. There is a FAQ on that.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#161346 - 2006-04-28 08:37 PM Re: Help with WSHPIPE()... I think. =P
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Based off of your suggestion Les, I tried a bit of research and most of all I could find for redirecting STDOUT and STDERR is with Unix commands. Microsofto published this:

http://www.microsoft.com/resources/docum...n.mspx?mfr=true

..but it doesnt' say how to redirect both to an output file. this is what i tried but it only wrote out STDERR and it didn't write it to a file:

psgetsid >&2 c:\errors.txt

the FAQ you're talking about, is that an FAQ on KORG?

Top
#161347 - 2006-04-28 09:20 PM Re: Help with WSHPIPE()... I think. =P
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You really need to learn how to search. Did you try searching our very own FAQ section for the two words STDOUT STDERR?

http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB10&Number=81614
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#161348 - 2006-04-28 09:27 PM Re: Help with WSHPIPE()... I think. =P
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
following the advice from your own link...

dir >c:\file.txt 2>&1

psgetsid >c:\errors.txt 2>&1

This of course assumes that psgetsid properly outputs to STDOUT and STDERR.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#161349 - 2006-04-28 09:58 PM Re: Help with WSHPIPE()... I think. =P
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Quote:

You really need to learn how to search.



I thought I was with the Microsoft link...

And based off of that doc, I tried the exact string you did but it immdediately executes. well, nm, i see my mistake. it did work, it just didn't run for the whole domain without the \\* so it executed quickly. thanx as always and sorry to bother.

Top
#161350 - 2006-04-28 10:06 PM Re: Help with WSHPIPE()... I think. =P
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I meant how to search korg...
The default is "newer than 3 years" but many of the FAQs are more than 3 years old.

Obviously, you managed to search the internet.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 918 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.11 seconds in which 0.072 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org