#139359 - 2005-05-08 01:42 PM
Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
Hi - I am going crazy here trying to get this to work !
I am using Sysinternals psservice.exe to enumerate a service on another server. From a command prompt, the following works:
"C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent" > "test54.txt"
The full paths need to be there for another reason I wont go into now. I have replicated the exact command line string in Kix, but it wont gernerate the piped output:
$source = CHR(34) + "C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" + CHR(34)
$dest = CHR(32) + CHR(62) + CHR(32) + CHR(34) + "test54.txt" + CHR(34)
$command = $source + " \\hocacomms1 query " + CHR(34) + "totalcoms agent" + CHR(34) + $DEST
SHELL $COMMAND ? $COMMAND
This gives:
"C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent" > "test54.txt"
I cant understand why it wont piep as in normal CMD window ?
Also, it seems that if the string is wider than the CMD window in windows, the string starts to write over itself....
I really just need to get this command to pipe output to a text file through kix, it workls PERFECTLY in a batch file
Edited by Brant_Winter (2005-05-08 01:43 PM)
|
|
Top
|
|
|
|
#139361 - 2005-05-08 01:55 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
See the FAQ: Not quite everything you wanted to know about RUN and SHELL
Quote:
If you want to use PIPE "|" or redirect ">" or ">>" then you must include the command interpreter.
|
|
Top
|
|
|
|
#139364 - 2005-05-08 02:26 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
I tried your code, but I am still not getting any text file created??
SetOption("WrapAtEOL","ON") $COMMAND = ' %COMSPEC% /C "C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent" > "test54.txt" ' ? $COMMAND SHELL $COMMAND
|
|
Top
|
|
|
|
#139366 - 2005-05-08 02:31 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
Actually, eben if I just run the code now without the redirect I get a blank CMD output screen:
SetOption("WrapAtEOL","ON") SHELL ' %COMSPEC% /C "C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent"'
When I ran this before with my code, I at least get the service status info show on the CMD screen.
|
|
Top
|
|
|
|
#139367 - 2005-05-08 02:34 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
ERROR: 2 - The system cannot find the file specified.
I had big probs getting the thing to run initially with the spaces in the path and also the "totalcoms agent" quotes in the middle of it all.....
|
|
Top
|
|
|
|
#139369 - 2005-05-08 02:42 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
back to the original error message i was getting, this is what took me days to fix....i eventually got the string to not break after that first space after Program...
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
ERROR: 1 - Incorrect function.
|
|
Top
|
|
|
|
#139370 - 2005-05-08 02:52 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
I am seaching for already built remote service UDF's but cant find a thing ??? Do you have a link ?
Edited by Brant_Winter (2005-05-08 02:53 PM)
|
|
Top
|
|
|
|
#139372 - 2005-05-08 02:58 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
SetOption("WrapAtEOL","ON") SHELL'%COMSPEC% /C "C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent"'
? "ERROR: @ERROR - @SERROR"
|
|
Top
|
|
|
|
#139373 - 2005-05-08 03:02 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
I havent put the redirect code on the string because I am trying to get this much to work at least first.
|
|
Top
|
|
|
|
#139376 - 2005-05-08 03:18 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
Quote:
Show us the batch file
Code:
@echo off "C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent" > "C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\STATE.txt" pause
|
|
Top
|
|
|
|
#139377 - 2005-05-08 03:20 PM
Re: Cant pipe output in SHELL - tried for 4 days now !
|
Brant_Winter
Fresh Scripter
Registered: 2005-05-08
Posts: 26
|
Shawn - Your last code works fine, I now just need to pipe to a text file in that god awful path..
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1260 anonymous users online.
|
|
|