Page 1 of 1 1
Topic Options
#21312 - 2002-05-07 10:03 PM Redirection to NUL
Duncan Bachen Offline
Fresh Scripter

Registered: 2002-05-07
Posts: 5
If I isuue the following command directly from a command prompt:

reg add HKCU\Environment\REG_LET=$REG_LET > NUL

It properly redirects the output to NUL. In this case the reg add gives an error message if the key already exists.

However, if from within the kix script I issue the command:
Shell "reg add HKCU\Environment\REG_LET=$REG_LET > NUL"
It is not properly redirecting it to NUL. Instead, the reg.exe is thinking that the > NUL is part of one of its arguments.

Isn't the shell function simply issuing the same command as if I typed it in manually?

*Waiting for the Apple to hit him in the head*
-Duncan

Top
#21313 - 2002-05-07 10:05 PM Re: Redirection to NUL
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Try
code:
Shell "%comspec% /c /e:1024 reg add HKCU\Environment\REG_LET=$REG_LET > NUL"

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

Top
#21314 - 2002-05-07 10:48 PM Re: Redirection to NUL
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
For the whole story, check out the FAQ.

(almost) everything you wanted to know about RUN and SHELL
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#21315 - 2002-05-08 03:39 PM Re: Redirection to NUL
Duncan Bachen Offline
Fresh Scripter

Registered: 2002-05-07
Posts: 5
quote:
Try

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

Shell "%comspec% /c /e:1024 reg add HKCU\Environment\REG_LET=$REG_LET > NUL"

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

I did, and I got an error about syntax. I looked a little closer and realized that on the Windows 2000 box I am using, the syntax is different.
/E from the good ol' DOS days used to let you set the size of the environment, however, with the W2K cmd.exe /E turns command extensions on/off.
So its /E:On or /E:OFF

Once I removed th /E argument it worked.

Thanks

Top
#21316 - 2002-05-08 03:41 PM Re: Redirection to NUL
Duncan Bachen Offline
Fresh Scripter

Registered: 2002-05-07
Posts: 5
quote:
For the whole story, check out the FAQ.

(almost) everything you wanted to know about RUN and SHELL


Hopefully that won't find it's way off the boards any time soon!

I tried find a FAQ that would cover this (and other questions) but haven't had any luck. Is there a formally maintained FAQ somewhere?

The biggest thing was understanding that you can't do any redirection with specifying the command interpreter. Once that's understood it makes life easier!

I also always just redirected to > NUL, I didn't realize you could specify 1>NUL and 2>NUL to differentiate between standard output and error output.

-D

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
1 registered (Allen) and 363 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.051 seconds in which 0.021 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