On Fri, 09 May 2008 20:01:36 -0700, moonhkt wrote:
> On May 10, 4:28 am, Ted Davis <tda...@[EMAIL PROTECTED]
> wrote:
>> On Fri, 09 May 2008 10:36:27 -0700, moonhkt wrote:
>> > Hi All
>>
>> > D:\Example\Software\awk>uname -a
>> > CYGWIN_NT-5.1 moon 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
>>
>> You might prefer a pure Windows port:
>> <http://gnuwin32.sourceforge.net/packages/gawk.htm>
>>
>> There are a few differences from Unix usage, mostly the command line
>> syntax and the fact that Windows doesn't implement some functions.
>>
>> In Windows, the oneliner for your tag.awk would be
>>
>> awk "BEGIN{print \"eric\"}"
>>
>> There is no /dev/null in Windows - it's just 'nul'.
>>
>> --
The subject says "Windows" - some of your syntax indicates Windows, but
the rest of it is either Unix or Cygwin. They don't mix.
>
> in tag.bat
> @[EMAIL PROTECTED]
off
> gawk 'BEGIN{print "eric"}'
NO - Windows requires Windows quoting conventions, not Unix conventions.
I have already given you the correct quoting.
>
> In Dos Prompt, run tag.bat ok
> D:\Example\Software\awk>tag
> eric
Not in Windows under CMD.exe it doesn't. Screen dump:
c:\myfiles>test
gawk: cmd. line:1: 'BEGIN{print
gawk: cmd. line:1: ^ invalid char ''' in expression
>
> D:\Example\Software\awk>tag
> eric
>
> Do you know how to run tag.awk in prompt ?
>
> D:\Example\Software\awk>cat tag.awk
> #!/usr/bin/gawk
> gawk 'BEGIN{print "eric"}'
> D:\Example\Software\awk>
That is mixed Unix and Windows syntax - it does't work. CMD.EXE does not
recognize shebang lines, and /usr/bin/gawk is meaningless to CMD - bash
understands shebangs, and Cygwin and *ix systems provide that file system
structure and syntax.
It is clear that you have some of the Gnu utilities, possibly in the form
of a Cygwin package. If you launch Cygwin the way you are supposed to,
you have a bash shell, and Linux syntax and shell scripts mostly work - if
you try to use the tools directly, you *must* use Windows conventions.
This screen dump is a typical Cygwin bash prompt:
user@[EMAIL PROTECTED]
~
$
>
> like
> D:\Example\Software\python>hello1.py
> 4
>
> D:\Example\Software\python>cat hello1.py #!/usr/bin/python # 2007/02/08
> eric
> print 4
> D:\Example\Software\python>
There are a couple of ways to associate a file extension with an
aplication, but since awk requires a switch (-f) in front of the script
name, and usually other arguments as well, it doesn't make much (if any)
sense to make that association. I find it useful to associate the .awk
extension with my text editor so when I click on a script, it opens in the
editor where I can work on it.
You can associate the extension with a batch file
RUNAWK.CMD
@[EMAIL PROTECTED]
-f%*
which inserts the -f switch and passes the entire argument string to gawk.
The easy way is to right click on a sample .awk file in Windows Explorer
or My Computer and select "Open with", then browse to gawk.exe and check
the "Always use ..." box before clicking on OK.
My advice is to do one or both of these things, but do not try to mix
them:
A) learn and use the CMD interface provided as the default for XP and use
purely DOS/Windows syntax and conventions
B) install and activate Cygwin, and use the bash/Linux-like environment,
syntax, and conventions.
If you chose A and need to use more than one computer, you can install
gawk (with its DLLs, or a stand-alone version from the Garbo archive) on a
flash drive. Actually, you could install Cygwin that way, but it requires
manually finding and copying some DLLs, and creating a more sophisticated
startup batch file.
--
T.E.D. (tdavis@[EMAIL PROTECTED]
) MST (Missouri University of Science and
Technology)
used to be UMR (University of Missouri - Rolla).


|