Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As an example, I would like the following commands to put a dir listing with all subdirectories to StdOut

copy con test
/s^Z
dir `test`

So, after lines one and two, there's a file in the current directory called test containing /s. Line three doesn't work, of course, but I would like the result to be the same as

dir /s

. Perhaps a better for line 3 is

echo `test`

where I hope the result is

/s
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Backticks do not work the same in cmd as bash. You may be able to play around with type which is roughly equivalent to cat. Redirection isn't a high point for cmd, but the following may work[ish] for what I think you're asking:

COPY CON TEST
/S^Z
FOR /F %A IN ('TYPE TEST') DO ( DIR %A )

Replace % with %% if this will be run from a batch file instead of the command line.

share|improve this answer
    
Yikes, that's a terrible answer. Unfortunately, it looks like you're right. :( –  Limited Atonement Oct 23 '10 at 20:29
    
@Limited Sorry for the terrible answer. What exactly are you trying to accomplish with this? Are you building a cmd script to accept user input or something? If you wish to expand your question, I may be able to provide a better answer. –  jscott Oct 23 '10 at 22:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.