Discussion Locked

can I script the edit of a *.cfg file

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am using MRTG to log traffic on a switch. I would like to script the updating of the MRTG files. After the new *.cfg file is created I need to add three lines to the top of the file. This file can be manually updated using notepad, but I would like to make it part of the scripting. Any suggestion would be helpful

1 reply

by rawright

The old DOS COPY command should do the job. If the three lines you need to add are fixed, put them in a text file (lines.txt). In your script try the line:

copy lines.txt + xxxxx.cfg log.txt

This will append the contents of the xxxxx.cfg file to the contents of lines.txt and place it in log.txt. Then add:

del xxxxx.cfg
ren log.txt xxxxx.cfg

If this looks like it will address the problem, try it a few times from a command prompt before automating it with a script, just to be safe. The same process will work even if the three additional lines change, so long as there is some way you can get them into a file.

This discussion is closed to new replies.