Computing.Net > Forums > Programming > Batch Script for gzip/ack

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Script for gzip/ack

Reply to Message Icon

Name: some_sec_guy
Date: June 29, 2009 at 12:04:23 Pacific
OS: Windows 2003
Subcategory: Batch
Comment:

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 ack.pl -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?



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: June 29, 2009 at 12:31:35 Pacific
Reply:

You are using the variables wrong.

Untested

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


0

Response Number 2
Name: IVO
Date: June 29, 2009 at 12:34:29 Pacific
Reply:

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

echo.%date%


0

Response Number 3
Name: some_sec_guy
Date: June 29, 2009 at 12:48:09 Pacific
Reply:

I figured it was something small like that. Thanks guys.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Copy file, changing conte... Recommendations for a Boo...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Script for gzip/ack

Batch script for file copy www.computing.net/answers/programming/batch-script-for-file-copy/14874.html

XP Pro Batch Script -FOR loop issue www.computing.net/answers/programming/xp-pro-batch-script-for-loop-issue/16073.html

Batch Script for many files www.computing.net/answers/programming/batch-script-for-many-files/20371.html