Batch Script for gzip/ack

June 29, 2009 at 12:04:23
Specs: Windows 2003
There's a problem I'm having trying to automate the process of grepping proxy files. Currently my string looks like this.

@echo off
set /P %%G=Please Enter Date to Grep e.g. "*mmdd*":
gzip.exe -v -c -d d:\logs\%%G.gz | perl -i -h "phrase_to_grep" > "logs/%date%_filename.txt"

I'm trying to figure out a way to prompt the user for what files they want to search for based on date. As you can see I attempted to use %%G for my variable after it's set. Although, it doesn't recognize it because it's being used in the dir path.

Any suggestions?

See More: Batch Script for gzip/ack

Report •

June 29, 2009 at 12:31:35
You are using the variables wrong.


@echo off
set /P var=Please Enter Date to Grep e.g. "*mmdd*":
gzip.exe -v -c -d d:\logs\%var%.gz | perl -i -h "phrase_to_grep" > "logs/%date%_filename.txt"

Report •

June 29, 2009 at 12:34:29
You must set an environment variable. e.g. myVar, not an internal one as %%G as they are absolutely different animals. So code

set /P myVar=...

and then refer to the value entered as %myVar%.

More %date% is not suitable "as is" to be part of a pathname/filename. As date format is country dependent post what you gei by typing at prompt


Report •

June 29, 2009 at 12:48:09
I figured it was something small like that. Thanks guys.

Report •

Related Solutions

Ask Question