- MCP server with stdio transport for local use - Search episodes, transcripts, hosts, and series - 4,511 episodes with metadata and transcripts - Data loader with in-memory JSON storage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
152 lines
9.1 KiB
Plaintext
152 lines
9.1 KiB
Plaintext
Episode: 3720
|
|
Title: HPR3720: Practicing Batch Files With ECHO
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3720/hpr3720.mp3
|
|
Transcribed: 2025-10-25 04:37:46
|
|
|
|
---
|
|
|
|
This is Hacker Public Radio Episode 3,720 for Friday the 4th of November 2022.
|
|
Today's show is entitled, Practicing Batch Files with Echo.
|
|
It is part of the series' DOS.
|
|
It is hosted by Aoka, and is about 12 minutes long.
|
|
It carries a clean flag.
|
|
The summary is, more on DOS.
|
|
This time, it is using the Echo command with Batch Files.
|
|
Hello, this is Aoka, welcoming you to Hacker Public Radio in another exciting episode
|
|
in our ongoing DOS series, and we're getting near to the end, but we still got some stuff
|
|
to do.
|
|
Now, last time, we took a look at introducing the topic of Batch Files.
|
|
I want to develop that topic a little further, because Batch Files is a very important technique
|
|
in DOS, and so let's do some practicing, and we're going to practice using the Echo command.
|
|
Now, the time that I did this, and this will tell you how long ago it was, I actually had
|
|
a computer running DOS 6.22, and that was where I wrote all of this stuff and tested it
|
|
out, and made sure it, you know, in that DOS environment, it worked the way it's supposed
|
|
to.
|
|
I think most of what we've talked about probably works with free DOS, but I can't say that
|
|
I've tested everything in free DOS.
|
|
All right, just the times that I've gone into free DOS, everything has worked the way
|
|
I expected it to, but, you know, there might be some differences.
|
|
But with that, this is...
|
|
We're taking a look at stuff that I did, oh, I don't know, 25 or more years ago.
|
|
Maybe was 30 years ago, and time flies by when you're having fun.
|
|
So the first thing that I would suggest, if you're going to try some of this stuff, create
|
|
a temporary directory on your machine, just for playing around with these Batch Files.
|
|
It's a bad habit to save these things in the root directory.
|
|
Now, first, you may not remember which files are your test files and which are vital system
|
|
files, and later delete something important by mistake.
|
|
That's going to give you a bad day.
|
|
Second, the root directory, like all directories in DOS, can only hold a limited number of
|
|
files.
|
|
All right, now this goes back to the file allocation table, and we've talked about that
|
|
that there's, you know, the way that the file allocation table is built, there's a limit
|
|
on how many slots you can fill up with file names.
|
|
So that's another good reason not to put stuff in the root directory, create directories
|
|
to hold your stuff.
|
|
Another good reason to create a temporary directory is if you need to find one of them,
|
|
it's a lot easier if they're all in their own area.
|
|
So, you know, I created one called C colon, backslash, DOS temp, backslash, and put all of
|
|
my Batch file projects in there when I was working on writing up this particular tutorial.
|
|
Now the echo command controls what gets shown on the screen when you run a Batch file.
|
|
You can use the echo command to stop the display or to make something display as you wish.
|
|
For instance, a simple one line Batch file that you can create, if you wanted to, you
|
|
could do it using the copycon that we talked about in the last tutorial and just type it
|
|
in from the console.
|
|
But here's a one line Batch file, echo space.
|
|
Hello people, how is life in the carbon world?
|
|
Now, if you create this file and run it, you will see the sentence displayed on the screen.
|
|
When you run the program, you will see the computer type out, hello people, how is
|
|
life in the carbon world.
|
|
So try creating this file as test1.batch in your temporary directory.
|
|
Now, this echo command can be useful when you want to display some piece of text.
|
|
For instance, in many DOS installation programs, you would see something on the screen that
|
|
told you to wait while the installation program was doing something.
|
|
Or in a networked environment, you might use it to display a login message.
|
|
Now, another use of the echo command has to do with the way that Batch files normally
|
|
execute.
|
|
A Batch file just executes DOS files or commands in order.
|
|
Batch the same as if you were at the keyboard typing in each command.
|
|
Well, if you were at the keyboard, you would see each of the commands you type.
|
|
So try creating the following file, we'll call this test2batch.
|
|
And what are we going to put in that?
|
|
Well, we're going to do a little one line thing in test2.batch.
|
|
It says copy, space, test1batch, space, test1a.batch.
|
|
When you execute this file, you should see first your command itself running in your
|
|
current working directory, followed by the computer reply that a file was copied.
|
|
So the computer would then come back with, in this case, I'm assuming I'm in my DOS
|
|
temp directory.
|
|
See, colon, backslash, DOS temp, backslash is the prompt.
|
|
And what I see coming back to me from the echo command is copy, space, test1batch, space,
|
|
test1a.batch, and then under that, the computer says one file copied, and actually it's one
|
|
file parentheses S, close parentheses copied because it could have been more than one.
|
|
Now seeing this on the display on the screen may not bother you, but there are times when
|
|
you don't want to see it, or you don't want others to see what is in the file, such
|
|
as in the login script.
|
|
You can use the echo command to stop that.
|
|
So edit your test2.batch file to add the following line, and make it the very first line in
|
|
your file, echo, space, off.
|
|
Now run test2.batch again.
|
|
You will see that the command is no longer displayed on the screen.
|
|
However, the first line, which is echo, space, off, is displayed.
|
|
Well, there's a way to fix that too.
|
|
You can stop that by using the at symbol.
|
|
The thing that we're all familiar with now from email, email was less common in the DOS
|
|
days.
|
|
Now, you put an at symbol in front, at echo, space, off.
|
|
And what that does is the at symbol, at the beginning of any line, stops the display
|
|
of that line in the batch file.
|
|
You might think, well, is that like the REM command REM, remark, there's a big difference.
|
|
The REM command stops the line from being executed, but the at symbol still executes the
|
|
line.
|
|
It just stops the display.
|
|
Now in most batch files, it makes more sense to turn off the display of all commands.
|
|
So you usually see the at symbol used only in the very first line to turn off the display
|
|
of the echo command.
|
|
So at echo, space, off, and then do the rest of your batch file.
|
|
Now, what if you wanted to display a blank line?
|
|
Well, you might think the echo command all by itself with nothing after it would do the
|
|
trick, but you would be wrong in that case.
|
|
The echo command by itself asks the computer to respond whether echo is on or off.
|
|
So you would get something like echo is off displayed on the screen.
|
|
The way to get a blank line, well, there's several ways.
|
|
One is just to put an REM by itself on a line.
|
|
But another one is to use a plus sign immediately after the echo.
|
|
So you say, echo plus, no space comes immediately after that.
|
|
And that would give you a blank line.
|
|
Now just for fun, a little stupid DOS trick from the old days, we used to have fun playing
|
|
around with other people's computers through practical jokes.
|
|
So while the echo command is intended primarily for use within batch files, it can be used within
|
|
DOS.
|
|
It's just a command like any other command you can use.
|
|
So a practical joke you could pull on someone in the old DOS days was to get to their computer
|
|
while they were at the old water cooler and type the command echo off at the DOS prompt,
|
|
echo space off.
|
|
It would have the effect of turning off the display of the DOS prompt since only the
|
|
very geekiest of geeks had ever seen anything like this.
|
|
It drove most people crazy.
|
|
And this reinforces one of the things that is considered to be best practice, not always
|
|
observed in my experience, but I've been in a number of corporate environments where they
|
|
would stress that, you know, if you get up from your computer, you need to, you know,
|
|
immediately lock the screen and lock the computer.
|
|
Even a lot of times people just, oh, I'm just going to the bathroom and I'm going to
|
|
come back and I don't want to log in again and people wouldn't do it and that would give
|
|
you a chance to do these kinds of practical jokes.
|
|
But it is a best practice.
|
|
One of the reasons why it's in your interest to do this, by the way, if you're in one of
|
|
those environments, is that most often they have monitoring software that says who was
|
|
logged in when a particular command was issued or who was logged in when a particular
|
|
file was accessed.
|
|
And you could get in trouble for accessing something that you weren't supposed to and
|
|
you weren't even the one who did it.
|
|
It was someone else who did it on your computer, but it was under your log in.
|
|
So with that little look at best practices in the old days, this is a hookup for hacker
|
|
public radio signing off and is always encouraging you to support free software.
|
|
Bye bye.
|
|
You have been listening to Hacker Public Radio at HackerPublicRadio.org.
|
|
Today's show was contributed by a HBR listener like yourself.
|
|
If you ever thought of recording podcasts, then click on our contribute link to find
|
|
out how easy it really is.
|
|
Hosting for HBR has been kindly provided by an onsthost.com, the internet archive and
|
|
our syncs.net.
|
|
On this advice status, today's show is released under Creative Commons, Attribution 4.0
|
|
International License.
|