Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In DOS is there a command to perform a similar spool function in SQL or Script command in UNIX to create a log?

I want to print all command line output to a file but I don't want to use the echo command for each line.

I can do the following:

xx.cmd > xx.log

But, it would be nice to just click on the batch/cmd script and generate a log, so that I do not need to get into the command line.

Any help will be appreciated.

Dave

share|improve this question
add comment

2 Answers 2

Not that I know of, but you can work around the problem using a prefix like this:

call :start %* > test.log
goto :eof
:start
echo Your code goes here
share|improve this answer
    
Very nice. It recorded my execution of the bat/cmd script into the log. –  dave Jan 2 '13 at 22:43
    
+1 - You might want to include the parameters in your CALL: call :start %* >test.log –  dbenham Jan 3 '13 at 2:57
    
@dbenham: good point. –  Harry Johnston Jan 3 '13 at 3:01
add comment

I’m not sure I understand the question –– I especially don’t understand the “I don't want to use the echo command for each line” statement –– but if Harry’s answer is close to what you want, you might like this, too:

@echo off
(
   command1
   command2
   command3
     
) >log_file_name

And, of course, if you want to see the commands, leave out the @echo off.

share|improve this answer
    
I tried this solution, but the log file did not generated. Any idea what went wrong? –  dave Jan 2 '13 at 23:11
    
How did you run it? (I.e., from a Command Prompt, from (Win)+R, from a shortcut/icon, or some other way?) What did you see when you did it? Did the script run at all? Did it terminate normally or abnormally? –  Scott Jan 2 '13 at 23:19
    
I did a command line, (Win)+R, and right click the bat/cmd script to select "Run as administrator". I can see the command is executed in a compmand prompt window very fast, but no log is generated. –  dave Jan 2 '13 at 23:24
add comment

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.