Page 1 of 1 1
Topic Options
#112636 - 2004-01-27 09:15 PM Shell and redirectoutput
Grutte Pier Offline
Getting the hang of it

Registered: 2001-10-06
Posts: 52
Loc: Leeuwarden, The Netherlands
Hello,

I'am trying to get the output generated by the command
Code:

shell "ndir G: /spa"


into a text file.
I've tried :
Code:

shell "ndir G: /spa > C:\ndit.txt"
shell '%comspec% /c ""ndir G: /spa > "C:\ndit.txt"'


but both options give an error telling that this not the proper syntax for Ndir

while the folowing syntaxes in de cmd prompt work just fine :
Code:

ndir G: /spa
ndir G: /spa > ndir.txt



Can somone tell me what goes wrong?
Are some applications not working?

Thanks,

GP

Top
#112637 - 2004-01-27 09:57 PM Re: Shell and redirectoutput
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please read the FAQ Forum, Proper use of quotes .

Then fix the incorrectly aligned quotes or remove them alltogether. Also, please read up on the use of %COMSPEC%.
_________________________
There are two types of vessels, submarines and targets.

Top
#112638 - 2004-01-27 10:15 PM Re: Shell and redirectoutput
Grutte Pier Offline
Getting the hang of it

Registered: 2001-10-06
Posts: 52
Loc: Leeuwarden, The Netherlands
Sorry Jens

syntax in the question but not in the working code.

shell '%comspec% /c ""ndir G: /spa > "C:\ndit.txt"'
should be
shell '%comspec% /c "ndir G: /spa > C:\ndit.txt"'

And can you give me hint in where I can find the 5conspec% info?

Thanks

GP

Top
#112639 - 2004-01-27 11:09 PM Re: Shell and redirectoutput
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Code:

shell '%comspec% /c "dir C: > C:\ndit.txt"'


does work for me. Make sure that you have permissions to write where you try to write.
_________________________
There are two types of vessels, submarines and targets.

Top
#112640 - 2004-01-28 01:02 AM Re: Shell and redirectoutput
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
If you are looking to eventually parse through the piped output via script, you may wish to give WshPipe() - Pipes the results of a shell command to an array a try.
Top
#112641 - 2004-01-28 03:12 AM Re: Shell and redirectoutput
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Quote:

And can you give me hint in where I can find the 5conspec% info?





%COMSPEC% is just a variable that is set to point to your command interpreter. NT/2000/XP CMD.EXE for 9X COMMAND.COM Thus using the variable will automatically select the correct one to use.

It is often used for SHELL/RUN commands to execute external programs.

From a DOS (%COMSPEC%) prompt you can type SET and you should see the entry something like this on XP

ComSpec=C:\Windows\system32\cmd.exe

You can type CMD.EXE /? to get a list of the available options that it supports.

Top
#112642 - 2004-01-28 05:27 AM Re: Shell and redirectoutput
Grutte Pier Offline
Getting the hang of it

Registered: 2001-10-06
Posts: 52
Loc: Leeuwarden, The Netherlands
YES....
Chris S. that is what i should do. Thanks a lot I was my other option/question to ask. And the sollution is faster and cleaner. It is fun working with this language and bulletin board.

Thank you,

GP

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 1188 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.058 seconds in which 0.027 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