ID:81288
 
Not a bug
BYOND Version:454
Operating System:Windows XP Pro
Web Browser:Firefox 3.5.2
Applies to:Dream Daemon
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
The documentation is off and the example does not compile and when modified to run it does not do the expected results.
Numbered Steps to Reproduce Problem:
Just compile and run this
http://www.byond.com/docs/ref/info.html#/proc/shell
Code Snippet (if applicable) to Reproduce Problem:
mob/verb/dir(Path as text)
shell("dir [Path] > dir.out")
usr << file2text("dir.out")


Expected Results:
It to quote
"
This example displays the output of the "dir" command to the user.
"
Actual Results:
It throws an error when you compile it and when you correct it...It still fails... As much as I would love it to work as it is documented...
Does the problem occur:
Every time?
Yes It does.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
I really don't know
Workarounds:
None, Unless I had a way of getting the folder byond is in at run-time.
I can confirm this is happening, but I'm not quite sure what's going wrong or why. This will need a little more study.
This happens because shell() doesn't actually invoke the command shell on windows, so pipes and redirects (which are built-into the shell program) won't work. Instead it directly executes the passed argument. The reason we do things this way is to prevent the flickering of the DOS shell every time shell() is called.

You can workaround this by explicitly calling the DOS shell ("cmd") inside shell():

shell("cmd /D /C dir > dir.out")

Do ("help cmd") inside DOS for more info.

We'll update the reference accordingly. Good find.

Tried it and it works but why is a cmd box left to hang.

Edit:
Im not really sure what /D and /C mean but removing /D solves all of my problems. Thanks for the help
Added a note to the reference entry for "shell" to explain this quirk.