Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

-v var=<path> on windows
Hi all,

I'm running the gnuwin32 port of gawk 3.1.3 on win2k.

Im trying to pass a path to a gawk variable

I know that I need to escape the backslashes like

gawk -v var="c:\\path\\including blanks\\to\\file" ...

My problem now is that the path I want to pass to gawk comes from a
batch file parameter

gawk -v var="%1"

As expected gawk issues "warning: escape sequence '\x' treated as
plain 'x'" if %1 contains a backslash.


Does anyone know a way around this?


TIA Lorenz

Report this thread to moderator Post Follow-up to this message
Old Post
Lorenz Lenhardt
05-13-05 08:58 PM


Re: -v var=<path> on windows
On Thu, 12 May 2005 10:25:34 +0200, Lorenz Lenhardt <lorenz@famlen.de>
wrote:

>Hi all,
>
>I'm running the gnuwin32 port of gawk 3.1.3 on win2k.
>
>Im trying to pass a path to a gawk variable
>
>I know that I need to escape the backslashes like
>
>	gawk -v var="c:\\path\\including blanks\\to\\file" ...
>
>My problem now is that the path I want to pass to gawk comes from a
>batch file parameter
>
>	gawk -v var="%1"
>
>As expected gawk issues "warning: escape sequence '\x' treated as
>plain 'x'" if %1 contains a backslash.
>
>
>Does anyone know a way around this?
>
awk "BEGIN{var=ARGV[1]; ARGV[1]=\"\"; ARGC--;print var}" %1

all one line - with or without "" around the string.  Of course, in a
real-world program, sanity checking would be needed and also perhaps
more sophisticated ARGV/ARGC handling


--
T.E.D. (tdavis@gearbox.maem.umr.edu)
SPAM filter: Messages to this address *must* contain "T.E.D."
somewhere in the body or they will be automatically rejected.

Report this thread to moderator Post Follow-up to this message
Old Post
Ted Davis
05-13-05 08:58 PM


Re: -v var=<path> on windows
"Lorenz Lenhardt" <lorenz@famlen.de> wrote in message
 news:6046819ss5asp8ksf5mvmb0iu78tnstf7r@
4ax.com...
> Hi all,
>
> I'm running the gnuwin32 port of gawk 3.1.3 on win2k.
>
> Im trying to pass a path to a gawk variable
>
> I know that I need to escape the backslashes like
>
> gawk -v var="c:\\path\\including blanks\\to\\file" ...
>
> My problem now is that the path I want to pass to gawk comes from a
> batch file parameter
>
> gawk -v var="%1"
>
> As expected gawk issues "warning: escape sequence '\x' treated as
> plain 'x'" if %1 contains a backslash.
>
>
> Does anyone know a way around this?
>
>
> TIA Lorenz

one way:
set VAR1=%1
gawk -v vv="VAR1" .... var=ENVIRON[vv]; ...

--
pop is Mark
If all is not lost, where is it?
--



Report this thread to moderator Post Follow-up to this message
Old Post
pop
05-13-05 08:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:56 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.