views:

3061

answers:

5

I want to print the output of a program in MS-DOS so I wrote a .bat file that says:

cls
ruby foo.rb

But the output - as it appears on my command prompt - looks like this:

c:\workspace>ruby foo.rb
foo output
c:\workspace>

I wanted to insert a newline into the output using MS-DOS because I don't want to pollute my Ruby code with anything not related to what the code is supposed to be doing.

The only commands in MS-DOS that look like what I want are 'type' and 'print' but both are for printing files.

I tried creating a text file with two blank lines and outputting it using the 'type' command but it looks messy.

Any ideas would be appreciated.

+2  A: 

Try this

echo.
Alex Reitbort
+1  A: 

Use the echo command followed by a period to display a new line in an MS-DOS batch file:

echo.
ahockley
+8  A: 

echo. will produce a new line.

so your script should look something like this:

@ECHO OFF
cls
echo.
ruby foo.rb

-John

John T
You saved me from certain death. Thank you.
Bryan Locke
A: 

I'm not clear on what you want here, but maybe this will help.

If you want the output sent to somewhere else, use the dos output "pipe".

ruby foo.rb > out.txt

will output the output of the ruby command to the out.txt file.

If you want to control the output, use ECHO.

@ECHO OFF/ON //turns off/on command output
ECHO "Blah" //writes "Blah" to the console.
ECHO //writes a blank line to the console.
StingyJack
+3  A: 

how about:

@echo off
cls
echo.
ruby foo.rb
echo.

bye

NoWhereMan
aww, StingJack came first :)
NoWhereMan
that upvote is for trying... 80)
Keng
ha! thank you =)
NoWhereMan