Using dos/windows environment variables in gawk script 
Author Message
 Using dos/windows environment variables in gawk script



% All the computers have an environment variable that points to the temp
% directory on the computer, however. The problem I'm having is that when
[...]

% C:\Awkstuff\Scripts\Ver2>gawk -f setscandir.awk
% gawk '{printf "%s\n", $0}' ..\\scanlist.txt > '%temp%\testdirlist.tmp'
% cannot create %temp%\testdirlist.tmp: directory nonexistent

It's not clear to me what's going on here. This looks like two different
commands, one which uses the -f switch to read a script from a file,
and the other has the script given on the command-line, and using
the command-line to redirect to a file. Are they related in some way?

One thing you could do is build the file name in your awk script:
 BEGIN { fname = ENVIRON["TEMP"] "\\testdirlist.tmp" }
 { print > fname }

--

Patrick TJ McPhee
East York  Canada



Tue, 14 Jan 2003 03:00:00 GMT  
 Using dos/windows environment variables in gawk script
Yeah, I should have been clearer on that... the second script was actually
generated inside the first...

Anyhooo, your solution works :)

Thanks :)

Rob

Quote:



> % All the computers have an environment variable that points to the temp
> % directory on the computer, however. The problem I'm having is that when
> [...]

> % C:\Awkstuff\Scripts\Ver2>gawk -f setscandir.awk
> % gawk '{printf "%s\n", $0}' ..\\scanlist.txt > '%temp%\testdirlist.tmp'
> % cannot create %temp%\testdirlist.tmp: directory nonexistent

> It's not clear to me what's going on here. This looks like two different
> commands, one which uses the -f switch to read a script from a file,
> and the other has the script given on the command-line, and using
> the command-line to redirect to a file. Are they related in some way?

> One thing you could do is build the file name in your awk script:
>  BEGIN { fname = ENVIRON["TEMP"] "\\testdirlist.tmp" }
>  { print > fname }

> --

> Patrick TJ McPhee
> East York  Canada




Tue, 14 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using exec in DOS/Windows environment

2. Reading DOS environment variables from c4b

3. CW20 and DOS environment variables

4. getting (DOS) environment variables

5. DOS environment variables

6. CW + Dos environment variables

7. DOS Clipper environment variable

8. DOS SET command or set environment variable from Rexx

9. Dos environment variables

10. DOS Environment Variables

11. SET Environment variable in DOS, HOW to?

12. Accessing DOS Environment Variables.

 

 
Powered by phpBB® Forum Software