When I run awk from the emx.exe with the following:
/c:/# awk -f test.txt
and I get the following error (Please view error in a fixed
width font):
awk: test.txt:1: BEGIN {}
' in expression: ^ invalid char '
test.txt is:
BEGIN {}
{
print $0, "hello"
}
END {}
The above error happens with all files I try to run with
the -f flag. I use the EPOC Text Editor version 1.41(049)
on a Psion 5mx with your most recent download
(20020813). I installed emxuser, emxshutils, and
emxgawk - in that order.
using awk without the -f flag e.g.
awk '{print $0, "hello"}'
works fine.
I have been after awk for my Psion since I got it, so I am
delighted with this package. If you need any further
details don't hesitate to email me at:
wm_wragg@yahoo.co.uk
Regards,
Wm.
Logged In: NO
Sorry my mistake. EMX uses binary format, therefore gawk is
expecting LF not CRLF. I found an editor which does this on
epoc:
http://www.starship.freeserve.co.uk/vim.html
just set fileformat=unix and everything works correctly.
Logged In: NO
wm_wragg@yahoo.co.uk
Sorry my mistake. EMX use binary format, so gawk is
expecting LF but gets CRLF instead. I found an editor for
epoc which will output LF instead:
http://www.starship.freeserve.co.uk/vim.html
and set fileformat=unix. This does the trick and everything
works correctly now.
Logged In: NO
I had the same problem; the -f flag works fine, but awk
expects Unix-style awk scripts with lines terminated by a
linefeed \n or 0x0a. Psion produces DOS-style text files with
lines terminated by carriage return + linefeed \r\n or 0x0d
0x0a. Awk is objecting in your example to the carriage return
\r at the end of each line.
The answer is to use a DosToUnix command to convert the
awk script first (this can still be opened by the Symbian text
editor without problems).
This script below, /bin/nawk, accepts the same commands as
awk and does the conversion on the fly then calls awk with
the converted file (I wrote it to a temporary file just to be
safe, but it could convert the source file as easily)
#!/bin/sh
#
# What
# Shellscript: nawk - DOS to UNIX text file
conversion of awk script
# and then invokes awk with converted awk script
#
if [ $# -gt 0 ]; then
if [ "$1" = '-f' ]; then
file="$2"
shift
shift
cat "$file" | /bin/awk -- 'BEGIN { RS="\r\n"; ORS="\n" }{
print }' >tmp.$$
/bin/awk -f 'tmp.$$' "$@"
rm 'tmp.$$'
exit 0
fi
fi
; JohnC