Page 1 of 2 12>
Topic Options
#139359 - 2005-05-08 01:42 PM Cant pipe output in SHELL - tried for 4 days now !
Brant_Winter Offline
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
#139360 - 2005-05-08 01:54 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
You need to add %COMSPEC% (cmd) in there, to get redirection working, like this (use single quotes to help delinate the double-quotes) :

SHELL ' %COMSPEC% /C "C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent" > "test54.txt" '

-Shawn

Top
#139361 - 2005-05-08 01:55 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Howard Bullock Offline
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.


_________________________
Home page: http://www.kixhelp.com/hb/

Top
#139362 - 2005-05-08 02:14 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Les Offline
KiX Master
*****

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

Also, it seems that if the string is wider than the CMD window in windows, the string starts to write over itself....



Not really.
See SetOption() in the manual and specifically WrapAtEOL.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139363 - 2005-05-08 02:16 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
There are multiple UDFs posted already that provide information about remote services.
_________________________
There are two types of vessels, submarines and targets.

Top
#139364 - 2005-05-08 02:26 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Brant_Winter Offline
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
#139365 - 2005-05-08 02:31 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Echo out the @ERROR/@SERROR after the SHELL command like this:

? "ERROR: @ERROR - @SERROR"

-Shawn

Top
#139366 - 2005-05-08 02:31 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Brant_Winter Offline
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 Offline
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
#139368 - 2005-05-08 02:36 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Take out that first space at the very beginning before %COMSPEC% ...

SHELL ' %COMSPEC% ...

Top
#139369 - 2005-05-08 02:42 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Brant_Winter Offline
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 Offline
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
#139371 - 2005-05-08 02:56 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Please post your latest code.
Top
#139372 - 2005-05-08 02:58 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Brant_Winter Offline
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 Offline
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
#139374 - 2005-05-08 03:07 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Try this:

SHELL'%COMSPEC% /C ""C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent""'

-Shawn

Top
#139375 - 2005-05-08 03:09 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Les Offline
KiX Master
*****

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

it workls PERFECTLY in a batch file



Show us the batch file. Also please post between code tags so that the line doesn't break on a space.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139376 - 2005-05-08 03:18 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Brant_Winter Offline
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 Offline
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
#139378 - 2005-05-08 03:24 PM Re: Cant pipe output in SHELL - tried for 4 days now !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
This should nail it then:

SHELL'%COMSPEC% /C ""C:\Program Files\Symantec\LiveState Recovery\Advanced Server 3.0\Agent\CommandFiles\psservice.exe" \\hocacomms1 query "totalcoms agent" >"test54.txt""'

-Shawn

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 1067 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.241 seconds in which 0.211 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