Carriage Return, Another one

August 22, 2011 at 12:43:03
Specs: Windows 7, 3.0GHz, 8GB
I was reading through the forum and found a discussion about this, but it was locked and I couldn't reply.

What I'm trying to do:

I have a program that will generate an output based on whatever batch file I create for it. The program will provide data and as long as I tell it what batch file to run, it will run the batch file and then take the list of variables I give it and do things with them as I see fit.


The program will execute this line:

message.bat "value1" "value2" "value3" "value4" "value5" "value6" "value7" "value8" "value9"

One of these things it does is this:

echo parameter 1 name: %1 >> c:\Interface\alert.txt
echo parameter 2 location: %2 >> c:\Interface\alert.txt
echo parameter 3 profile: %3 >> c:\Interface\alert.txt
echo parameter 4 trigger: %4 >> c:\Interface\alert.txt
echo parameter 5 alert: %5 >> c:\Interface\alert.txt
echo parameter 6 severity: %6 >> c:\Interface\alert.txt
echo parameter 7 purpose: %7 >> c:\Interface\alert.txt
echo parameter 8 message: %8 >> c:\Interface\alert.txt
echo parameter 9 description: %9 >> c:\Interface\alert.txt

But what I would also like to do is add a return at the end that will create a blank line or two to separate the data that is being logged. I'd also like for it to return the date as the first line. I'll be looking around the site to see if I can find how that works, I'm sure it's easy to pull the system time.

But I would like for it to look like this in the "log" file.


MM/DD/YYYY HH:MM:SS
parameter 1 name: value1
parameter 2 location: value2
parameter 3 profile: value3
parameter 4 trigger: value4
parameter 5 alert: value5
parameter 6 severity: value6
parameter 7 purpose: value7
parameter 8 message: value8
parameter 9 description: value9

MM/DD/YYYY HH:MM:SS
parameter 1 name: value1
parameter 2 location: value2
parameter 3 profile: value3
parameter 4 trigger: value4
parameter 5 alert: value5
parameter 6 severity: value6
parameter 7 purpose: value7
parameter 8 message: value8
parameter 9 description: value9

This is basically what I'm looking to do. I will look around for the date insertion, but what about the carriage return? I've read through some post, but it seemed more complicated than it should be. That or I just wasn't understanding. And please keep in mind, I am new to this and know just a little on coding things. I'm learning and want to learn though.

Thanks in advance for your help,


Jon


See More: Carriage Return, Another one

Report •


#1
August 22, 2011 at 16:01:35

Report •

#2
August 23, 2011 at 05:43:38
echo returns a line of echo is on. Is there no way to insert a blank line or carriage return? Or even a blank line before the first line would be good.

Report •

#3
August 23, 2011 at 05:58:07

Report •

Related Solutions

#4
August 23, 2011 at 06:09:16
Thanks Razor. I did make sure to add the period and it returned this:

Time and Date of incident: 8:01:18.55 Tue 08/23/2011
parameter 1 name: value1
parameter 2 location: value2
parameter 3 profile: value3
parameter 4 trigger: value4
parameter 5 alert: value5
parameter 6 severity: value6
parameter 7 purpose: value7
parameter 8 message: value8
parameter 9 description: value9
ECHO is on.
Time and Date of incident: 8:03:43.12 Tue 08/23/2011
parameter 1 name: value1
parameter 2 location: value2
parameter 3 profile: value3
parameter 4 trigger: value4
parameter 5 alert: value5
parameter 6 severity: value6
parameter 7 purpose: value7
parameter 8 message: value8
parameter 9 description: value9
ECHO is on.

I'm running 2008R2, not sure what version of DOS this is. And this script will eventually be run on 2003 servers, so there needs to be functionality across multiple platforms. And I added the date and time to the original code above, that was easy. :)

Am I missing something?


Report •

#5
August 23, 2011 at 07:06:48
Am I missing something?
The period.

C:\>echo
ECHO is on.

C:\>echo.


C:\>
Win7

How To Ask Questions The Smart Way


Report •

#6
August 23, 2011 at 07:48:08
Well I must have been seeing things! hehe I added the period and it did return the null line, but when writing to a file it doesn't create the blank line separation between the two entries being created. I tried before and after the information I have posted above and I got the same output. I even tried using multiple lines of echo., and it still writes the same.

I think for now I'm just going to insert a line of equals (=) to break up the text. No need to get complicated on this, just was hoping it would be simple solution.

Razor, thanks for your input!


Report •

Ask Question