Page 1 of 1 1
Topic Options
#121180 - 2004-06-13 08:47 PM command line syntax for SHELL
Udaloy Offline
Fresh Scripter

Registered: 2003-09-08
Posts: 31
Loc: Ohio
Ok, I searched and found this advice for using DOS prompt commands in a script Code:
 
Start with a two line script:

code:
--------------------------------------------------------------------------------

SHELL '%COMPSPEC% /c \\NEO\SysUpdates\OSUpdates\Q318203_MSXML30_x86_en.exe /q:a /c:"dahotfix.exe /q /n"'? "Error code returned: @error"

--------------------------------------------------------------------------------

and execute it from a DOS window. Shorten it until you see some result.

Or would you need another set of quotes for %Comspec%?

code:
--------------------------------------------------------------------------------

SHELL "%COMPSPEC% /c '\\NEO\SysUpdates\OSUpdates\Q318203_MSXML30_x86_en.exe /q:a /c:"dahotfix.exe /q /n"'"






My question is how do I fomat it, while using a variable from the script? Something like this is what I have
Code:
 	Shell '%COMPSEC% /c \\<server>\<share>\showmbrs <domain>\'+$group+' >> \\<machine>\<share>\'+$group+'.txt'

?'errors: '+@ERROR+@SERROR




The error that it returns is "2. The system cannot find the file specified." The script is reading from a flat file, the names of domain groups, and then using it to enumerate the users for that group, and piping it out to a file with the name of the group as the file name. Perhaps someone has done something similar? Any help would be greatly appreciated.

Top
#121181 - 2004-06-13 09:21 PM Re: command line syntax for SHELL
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See the FAQ forum on the use of RUN/SHELL and quotes.

You shoudl rather assembe the shell command as a string and then feed toe compleet strng into SHELL
Code:

$shellcmd='%COMPSEC% /c \\<server>\<share>\showmbrs "<domain>\'+$group+'" >> "\\<machine>\<share>\'+$group+'.txt"'
? 'SHELL command = '$shellcmd
SHELL $shellcmd

_________________________
There are two types of vessels, submarines and targets.

Top
#121182 - 2004-06-13 09:42 PM Re: command line syntax for SHELL
Udaloy Offline
Fresh Scripter

Registered: 2003-09-08
Posts: 31
Loc: Ohio
Well, I tried what you suggested, and it still returns with "The system cannot find the file specified."

I can run this command at the DOS prompt without any issues. What exactly does the /c parameter mean for %COMSPEC%?

I even tried it this way without luck (after mapping the Z: drive).
Code:
 $shellcmd='%COMPSEC% /c z:\showmbrs "kent\'+$group+'" >> "c:\'+$group+'.txt"' 




Thanks.

Top
#121183 - 2004-06-13 10:18 PM Re: command line syntax for SHELL
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I'm pretty sure Code:

'%COMPSEC%


will actually mean Code:

'%COMSPEC%



For the meaning of /c see the command prompt help %COMSPEC% /? !


Edited by sealeopard (2004-06-14 02:35 AM)
_________________________
There are two types of vessels, submarines and targets.

Top
#121184 - 2004-06-13 11:26 PM Re: command line syntax for SHELL
Udaloy Offline
Fresh Scripter

Registered: 2003-09-08
Posts: 31
Loc: Ohio
Jens,

Read about the use of quotes, but it was the COMSPEC typo that killed me. I think I would have gone nuts, and never saw it. Thanks a lot.

Udaloy

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.105 seconds in which 0.066 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