Edit a TXT file via batch file...

G

Guest

I need to be able to print out an output file which will contain a user id and pw... I need an automated process to edit these out entirely via the command prompt / batch file but can't seem to figure out how.

I can easily search for the string.. FINDSTR "rootadmin" or FIND "rootadmin" but I can't delete any strings in the text file. Is it possible to do what I need to do

Thanks
Mike
 
P

Phil Robyn [MVP]

Mike said:
I need to be able to print out an output file which will contain a user id and pw...
I need an automated process to edit these out entirely via the command prompt / batch
file but can't seem to figure out how.

I can easily search for the string.. FINDSTR "rootadmin" or FIND "rootadmin" but I can't
delete any strings in the text file. Is it possible to do what I need to do?

Thanks!
Mike

What kind of output file? Maybe messages from an FTP session? :) Whose userid and
password? Yours? Someone else's?

If the output file is in a particular predictable format (e.g., messages from an FTP
session), then it's pretty easy to remove the userid and password without having to
know what the userid and password are. If the output file is not in a predictable
format, and you don't know what the password is (because it's not yours), then it
will be pretty tough to remove the password, as you cannot search for something that
you do not know.
 
G

Guest

Hey Phil..
The user id and pw will be predictable every time...good point! ;) However, I am using a telnet wrapper which is is going to record an automated session where I will have a couple values returned. This entire session is going to be then output to a txt file.
As far as I know during this session I cannot turn off and then turn back on the logging to the txt file. It logs everything.
So... how can I have a batch file go to this txt output file and have it automatically delete / or modify the account/pw info??
Thanks
Mike
 
M

Matthias Tacke

=?Utf-8?B?TWlrZQ==?= said:
Hey Phil...
The user id and pw will be predictable every time...good point! ;)
However, I am using a telnet wrapper which is is going to record an
automated session where I will have a couple values returned. This
entire session is going to be then output to a txt file. As far as I
know during this session I cannot turn off and then turn back on the
logging to the txt file. It logs everything. So... how can I have a
batch file go to this txt output file and have it automatically delete
/ or modify the account/pw info??? Thanks, Mike

Hello Mike,
You could use
findstr /V "Account Password" logfile >changedlog
to omit the lines from the file.
And delete lofile afterwards.
HTH
 
M

Michael A. Covington

You could find a Windows implementation of "sed" (the popular UNIX string
editor, often used in UNIX scripts) and use that. You can call sed from the
command line with an argument saying what changes to make in the file.

There are Windows implementations of sed. Google should be able to find one
quickly.
 
P

Phil Robyn [MVP]

Mike said:
Hey Phil...
The user id and pw will be predictable every time...good point! ;) However, I am using a
telnet wrapper which is is going to record an automated session where I will have a couple
values returned. This entire session is going to be then output to a txt file.
As far as I know during this session I cannot turn off and then turn back on the logging
to the txt file. It logs everything.
So... how can I have a batch file go to this txt output file and have it automatically delete
/ or modify the account/pw info???
Thanks,
Mike

Post an actual example of the file or part of the file containing
the userid and password that is to be removed. Remember, if the
actual userid and password to be removed are not known, it will not
be possible to locate them using FIND or FINDSTR, because you will
not know what to specify as search arguments.
 
T

Torgeir Bakken (MVP)

Michael A. Covington said:
You could find a Windows implementation of "sed" (the popular UNIX string
editor, often used in UNIX scripts) and use that. You can call sed from the
command line with an argument saying what changes to make in the file.

There are Windows implementations of sed. Google should be able to find one
quickly.

Hi

I like the utilities on this site, it's a native Win32 port of many
GNU utilities, sed included:

http://unxutils.sourceforge.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top