[thelist] Old School DOS tricks

Burhan Khalid burhankh at hotmail.com
Mon Dec 10 20:44:35 CST 2001


Hey Listers :

  I hadn't posted a tip for a while, so I thought this might be a good time. 
Don't know how relevant this is, but I've always been a sucker for DOS ... 
works great in Windows :P


<tip author="Burhan Khalid type="DOS Output">
Have you ever wanted to print out your directory listing? One easy way to do 
this, is using output redirection (*nix people know what I'm talking about). 
Here is a short example :

C:\>dir /s > treelisting.txt

The output redirection ( > ) will pipe the output to the text file. Neat? Of 
course! Older DOS versions had a tree command, which would do a lot better 
in this situation, but, it isn't available with the limited DOS that comes 
with Windows. You can also, if you so incline, output it straight to your 
printer like this :

C:\>dir /s > lpt1

Assuming that your printer is connected to lpt1 (the default printer port). 
The only warning about using lpt1 comes with networked printers. Unless you 
specify that Windows maps lpt1 to your network printer, the above command 
will not work.

You can, of course, do the opposite (pipe input).

C:\myprogram.exe < mycommands.txt > myoutput.txt

I use this trick while tutoring C/C++ students. It also comes in handy when 
I'm checking programming compeition submissions. I can use a default input 
file, and use an output file to capture the program's output.
</tip>

<tip author="Burhan Khalid" type="Shorthand File Creation in DOS">
Usually, if you want to create a file in DOS, you would launch the built in 
editor :

c:\>edit myfile.txt

What if you don't have the editor available? You can still make a file, 
using the copy command :

c:\>copy con myfile.txt

Recall the copy command's syntax (shorthand) :

copy source destination

In this case, we have given the source of con (stands for console). This 
will simply drop the cursor to the next line :

c:\>copy con myfile.txt
_ < cursor

 From here, you can create your file. After you are done, you hit F6, which 
will terminate your input.

Complete example :
------------------

c:\>copy con myfile.txt
Neat ways to create files that I might have not known.
This guy spends way to much time on the computer.^Z
1 file(s) copied
C:\>_ < cursor
</tip>

I know I owe.
Burhan Khalid





_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp





More information about the thelist mailing list