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

AWKPATH question
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

Report this thread to moderator Post Follow-up to this message
Old Post
twf_cc
03-29-08 09:00 AM


Re: AWKPATH question

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.


Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
03-29-08 09:00 AM


Re: AWKPATH question
"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.


Report this thread to moderator Post Follow-up to this message
Old Post
Rajan
03-29-08 09:00 AM


Re: AWKPATH question
On 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

Report this thread to moderator Post Follow-up to this message
Old Post
twf_cc
03-30-08 12:09 AM


Re: AWKPATH question

On 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.


Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
03-30-08 12:09 AM


Re: AWKPATH question
On 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

Report this thread to moderator Post Follow-up to this message
Old Post
Steffen Schuler
03-30-08 12:09 AM


Re: AWKPATH question
Steffen 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.

Report this thread to moderator Post Follow-up to this message
Old Post
stan
03-30-08 03:10 AM


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 03:49 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.