Code Comments
Programming Forum and web based access to our favorite programming groups.I have set enviroment AWKPATH in ~/.bash_profile including ~/lib/awk
which contains some function
at command line using, there's no problem.
fang@bash ~
$ uname -a
CYGWIN_NT-5.1 bash 1.5.25(0.156/4/2) 2008-03-05 19:27 i686 Cygwin
fang@bash ~
$ echo $AWKPATH
/usr/lib/awk:/home/fang/lib/awk
fang@bash ~
$ echo abcd |awk -f reverse.awk --source '{print reverse($0)}'
dcba
put in a file ,I get an error
fang@bash ~
$ cat junk
#! /bin/gawk -f reverse.awk --source
{
print reverse($0)
}
fang@bash ~
$ echo abcd |./junk
gawk: fatal: can't open source file ` reverse.awk --source ' for
reading (No such file or directory)
calling gawk from shell, there's no problem
$ cat junk2
#! /bin/bash
gawk -f reverse.awk --source '{print reverse($0)}'
fang@bash ~
$ echo abcd | ./junk2
dcba
how to solve the problem, thanks
rgd
twf
Post Follow-up to this message
On 3/28/2008 10:56 PM, twf_cc wrote:
> I have set enviroment AWKPATH in ~/.bash_profile including ~/lib/awk
> which contains some function
> at command line using, there's no problem.
> fang@bash ~
> $ uname -a
> CYGWIN_NT-5.1 bash 1.5.25(0.156/4/2) 2008-03-05 19:27 i686 Cygwin
>
> fang@bash ~
> $ echo $AWKPATH
> /usr/lib/awk:/home/fang/lib/awk
>
> fang@bash ~
> $ echo abcd |awk -f reverse.awk --source '{print reverse($0)}'
> dcba
>
> put in a file ,I get an error
>
> fang@bash ~
> $ cat junk
> #! /bin/gawk -f reverse.awk --source
>
> {
> print reverse($0)
> }
>
> fang@bash ~
> $ echo abcd |./junk
> gawk: fatal: can't open source file ` reverse.awk --source ' for
> reading (No such file or directory)
>
> calling gawk from shell, there's no problem
>
> $ cat junk2
> #! /bin/bash
>
> gawk -f reverse.awk --source '{print reverse($0)}'
>
> fang@bash ~
> $ echo abcd | ./junk2
> dcba
>
> how to solve the problem, thanks
You probably haven't exported AWKPATH. This is more of an OS-specific issue
and
so is OT here so follow up at comp.unix.shell if that's not it.
Ed.
Post Follow-up to this message"Ed Morton" <morton@lsupcaemnt.com> wrote in message news:47EDBEAE.6080703@lsupcaemnt.com... > > > On 3/28/2008 10:56 PM, twf_cc wrote: > > You probably haven't exported AWKPATH. This is more of an OS-specific > issue and > so is OT here so follow up at comp.unix.shell if that's not it. > > Ed. > Looks like gawk is receiving the filename as "reverse.awk --source" instead of reverse.awk. comp.unix.shell is more appropriate.
Post Follow-up to this messageOn 3$B7n(B29$BF|(B, $B>e8a(B11$B;~(B59$BJ,(B, Ed Morton <mor...@lsupcaemnt.com> w
rote:
> On 3/28/2008 10:56 PM, twf_cc wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> You probably haven't exported AWKPATH. This is more of an OS-specific issu
e and
> so is OT here so follow up at comp.unix.shell if that's not it.
>
> Ed.
I have export enviroment var in bash_profile
fang@bash ~
$ cat .bash_profile | tail -n6
export NNTPSERVER='freenews.netfront.net'
export LYNX_CFG="$HOME/lynx.cfg"
export LESSCHARSET=latin1
#export LC_CTYPE=zh_CN.gbk
export CHARSET=GBK
export AWKPATH="/usr/lib/awk:$HOME/lib/awk"
fang@bash ~
$ pwd
/home/fang
fang@bash ~
$ unset AWKPATH
fang@bash ~
$ echo $AWKPATH
fang@bash ~
$ source .bash_profile
fang@bash ~
$ echo $AWKPATH
/usr/lib/awk:/home/fang/lib/awk
fang@bash ~
$ pwd
/home/fang
fang@bash ~
$
fang@bash ~
$ echo abcd | gawk -f reverse.awk --source '{print reverse($0)}'
dcba
fang@bash ~
$ cat junk
#! /bin/gawk -f reverse.awk --source
{
print reverse($0)
}
fang@bash ~
$ echo abcd | ./junk
gawk: fatal: can't open source file ` reverse.awk --source' for
reading (No such file or directory)
fang@bash ~
$
any ideas? thanks
Post Follow-up to this messageOn 3/29/2008 9:22 AM, twf_cc wrote: > On 3$B7n(B29$BF|(B, $B>e8a(B11$B;~(B59$BJ,(B, Ed Morton <mor...@ lsupcaemnt.com> wrote: > > > > I have export enviroment var in bash_profile <snip> > any ideas? thanks As I said, if that isn't the problem, follow up at comp.unix.shell. Ed.
Post Follow-up to this messageOn Fri, 28 Mar 2008 20:56:07 -0700, twf_cc wrote:
[snip]
> $ cat junk
> #! /bin/gawk -f reverse.awk --source
>
> {
> print reverse($0)
> }
>
[snip]
> $ echo abcd |./junk
> gawk: fatal: can't open source file ` reverse.awk --source ' for reading
> (No such file or directory)
[snip]
in many flavors of UNIX like the Linux emulation CYGWIN the shebang line
can only have one argument (option) and must be shorter than 32 bytes.
Therefore your shebang approach doesn't work.
Try:
------------------8<-------------------------------
#!/bin/igawk -f
@include reverse.awk
{
print reverse($0)
}
------------------8<-------------------------------
Perhaps you have to fix the igawk path in the shebang line.
Look at:
which(1)
igawk(1)
--
Steffen
Post Follow-up to this messageSteffen Schuler wrote: > On Fri, 28 Mar 2008 20:56:07 -0700, twf_cc wrote: > > [snip] > [snip] > [snip] > > > in many flavors of UNIX like the Linux emulation CYGWIN the shebang line > can only have one argument (option) and must be shorter than 32 bytes. > Therefore your shebang approach doesn't work. Are you sure about the size of the limit? I agree there is a limit but I thought it was more than 32 bytes. I know it is for the linux (suse) I have handy and I just tried cygwin with this: try.sh #! /home/smoore/ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa /bash.exe echo "hello" With no problems.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.