For Programmers: Free Programming Magazines  


Home > Archive > AWK > December 2005 > Moving my AWK script from SGI to LINUX









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Moving my AWK script from SGI to LINUX
Zeppyjnr

2005-12-01, 7:00 pm

Hi
I have a faithful awk script that I have been using on SGIs for years.
Last year we moved to Linux and my script stopped working, this was
fine I just "rlogin"ed to the SGI and ran the script there. Now it
seems that this will soon no longer be an option as more of our SGIs
get decommisioned every w.

Therefore I wondered, is there any common or documented reasons why
there should be such incompatibility? My script hangs at the very first
line, I wondered if it would be something to do with grammar?

The line it hangs on is

if(spin_table == "")spin_table=input(workfile,"Spin table name","")

This just prints to screen Spin table name then hangs.

Any suggestions would be very gratefully received!

Kenny McCormack

2005-12-01, 7:00 pm

In article <1133447056.937236.144560@f14g2000cwb.googlegroups.com>,
Zeppyjnr <ben.goult@astrazeneca.com> wrote:
....
>The line it hangs on is
>
>if(spin_table == "")spin_table=input(workfile,"Spin table name","")
>
>This just prints to screen Spin table name then hangs.


Well, I guess that just depends on what "input()" is, now doesn't it?

Zeppyjnr

2005-12-01, 7:00 pm

I run the program by pasting the following;

set funiq=/file.spin
set OFL=/file_seq_link_spin5.lst
set OFF=/file_seq_frag_spin5.lst
set OS=/tmp.spin
set fambg="/empty.txt"
set fseq=/file.seq

/asd/asdafsa/awk/seq_link_un.awk spin_table="$funiq $fambg" dltca=0.3 \
dltcb=0.4 dltco=0.3 sequence_name=$fseq fspin=$OS empty.txt | tee $OFL
/asd/asdafsa/awk/linkunq.awk debug=1 minlen=1 fout=$OFF.frag \
linkflag=1 ignoreamb=1 printall=1 $OFL | tee $OFF
date
exit


into a shell and the first few lines of the program seq_link_un.awk
are:

#!/usr/bin/awk -f
# dltcb=0.5
# dltca=0.3
# dltco=0.3
# dlth=0.03
# dltn=0.3
# fspin="seq_link_un.lst"
# showtype = show residue type flag [1]
# showlink = show spin link flag [1]
# typedlt = residue type limits +- delta [1]
# linkfunpower = Power to be used on the link deviation function [1]
# linkshift = shift on link function return value [0]
# make line numbering for Felix dba sequential
#
BEGIN {
a_tl[1]=50.0; a_tu[1]=55.0; b_tl[1]=16.0; b_tu[1]=22.0; n_t[1]="A"
### Get process number to open unique shell file
"echo $$" | getline workfile
workfile = workfile ".tmp"
workfile1 = workfile "1"
system("echo " workfile " temporary file for seq_link_un.awk >"
workfile)
getline i < workfile
### get parameters
if(dltcb=="") dltcb=0.5
if(dltca=="") dltca=0.3
if(dltco=="") dltco=0.3
if(dlth=="") dlth=0.03
if(dltn=="") dltn=0.3
if(fspin=="") fspin="seq_link_un.spin"
if(showtype=="") showtype=1
if(showlink=="") showlink=1
if(typedlt=="") typedlt=1
if(linkfunpower=="") linkfunpower=1
if(linkshift=="") linkshift=0
if(spin_table == "")spin_table=input(workfile,"Spin table
name","")
if(sequence_name == "")sequence_name=input(workfile,"Sequence
file name","")
dba_cnt=1
mxcol=10




It always hangs at the line if(spin_table ==
"")spin_table=input(workfile,"Spin table name","")

Any suggestions?

Cheers

Ben

Ed Morton

2005-12-01, 7:00 pm



Zeppyjnr wrote:
> I run the program by pasting the following;
>
> set funiq=/file.spin
> set OFL=/file_seq_link_spin5.lst
> set OFF=/file_seq_frag_spin5.lst
> set OS=/tmp.spin
> set fambg="/empty.txt"
> set fseq=/file.seq
>
> /asd/asdafsa/awk/seq_link_un.awk spin_table="$funiq $fambg" dltca=0.3 \
> dltcb=0.4 dltco=0.3 sequence_name=$fseq fspin=$OS empty.txt | tee $OFL
> /asd/asdafsa/awk/linkunq.awk debug=1 minlen=1 fout=$OFF.frag \
> linkflag=1 ignoreamb=1 printall=1 $OFL | tee $OFF
> date
> exit
>
>
> into a shell and the first few lines of the program seq_link_un.awk
> are:
>
> #!/usr/bin/awk -f
> # dltcb=0.5
> # dltca=0.3
> # dltco=0.3
> # dlth=0.03
> # dltn=0.3
> # fspin="seq_link_un.lst"
> # showtype = show residue type flag [1]
> # showlink = show spin link flag [1]
> # typedlt = residue type limits +- delta [1]
> # linkfunpower = Power to be used on the link deviation function [1]
> # linkshift = shift on link function return value [0]
> # make line numbering for Felix dba sequential
> #
> BEGIN {
> a_tl[1]=50.0; a_tu[1]=55.0; b_tl[1]=16.0; b_tu[1]=22.0; n_t[1]="A"
> ### Get process number to open unique shell file
> "echo $$" | getline workfile
> workfile = workfile ".tmp"
> workfile1 = workfile "1"
> system("echo " workfile " temporary file for seq_link_un.awk >"
> workfile)
> getline i < workfile
> ### get parameters
> if(dltcb=="") dltcb=0.5
> if(dltca=="") dltca=0.3
> if(dltco=="") dltco=0.3
> if(dlth=="") dlth=0.03
> if(dltn=="") dltn=0.3
> if(fspin=="") fspin="seq_link_un.spin"
> if(showtype=="") showtype=1
> if(showlink=="") showlink=1
> if(typedlt=="") typedlt=1
> if(linkfunpower=="") linkfunpower=1
> if(linkshift=="") linkshift=0
> if(spin_table == "")spin_table=input(workfile,"Spin table
> name","")
> if(sequence_name == "")sequence_name=input(workfile,"Sequence
> file name","")
> dba_cnt=1
> mxcol=10
>
>
>
>
> It always hangs at the line if(spin_table ==
> "")spin_table=input(workfile,"Spin table name","")
>
> Any suggestions?



a) define the function "input()"
b) stop using getline (this is awk, not C).

Ed.
Zeppyjnr

2005-12-01, 7:00 pm

Ok, I will try and improve my scripting but why would these problems
mess up the script on Linux when it works fine on SGI?

Ed Morton

2005-12-01, 7:00 pm

NNTP-Posting-Host: morton-2.ih.lucent.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
X-Accept-Language: en-us, en
In-Reply-To: <1133456012.128427.300340@g49g2000cwa.googlegroups.com>
Xref: number1.nntp.dca.giganews.com comp.lang.awk:33881


Zeppyjnr wrote:
> Ok, I will try and improve my scripting but why would these problems
> mess up the script on Linux when it works fine on SGI?
>


Please read this before posting again:

http://cfaj.freeshell.org/google

Now to your question: I was wrong, if you are really calling "input()"
then "input()" must be defined somewhere or you'd be getting an error
message about trying to call an undefined function, so the problem might
be that you're not calling "input()" at all because on your command line
you do set this variable:

spin_table="$funiq $fambg"

and then in your code you only call "input()" if that variable is not set:

if(spin_table == "")spin_table=input(workfile,"Spin table name","")

but that contradicts your statement that you see "Spin table name" in
the output and it also doesn't address the problem that "input()" is not
defined anywhere in your script.

Try using a different awk. If you ran gawk, you could use the "--lint"
flag to report undefined functions to get more information. Also, try
getting rid of as much of the code as possible while still being able to
reproduce the problem so you can narrow it down to a specific couple of
lines.

Also, search for the definition of "input()" and post that.

Ed.
Jürgen Kahrs

2005-12-01, 7:00 pm

Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 8+0N8gv+yTBvj7lNEqXlOgLfidpMeiIKuJdCtcOz
h6e8DH1wM=
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050921
X-Accept-Language: en-us, en
In-Reply-To: <1133456012.128427.300340@g49g2000cwa.googlegroups.com>
X-Enigmail-Version: 0.90.1.0
X-Enigmail-Supports: pgp-inline, pgp-mime
Xref: number1.nntp.dca.giganews.com comp.lang.awk:33882

Zeppyjnr wrote:

> Ok, I will try and improve my scripting but why would these problems
> mess up the script on Linux when it works fine on SGI?


If your script was easier to read, it would
be easier for us to help you.
Kenny McCormack

2005-12-01, 7:00 pm

In article <3v8r6eF14ogu5U1@individual.net>,
=?ISO-8859-1?Q?J=FCrgen_Kahrs?= <Juergen.KahrsDELETETHIS@vr-web.de> wrote:
>Zeppyjnr wrote:
>
>
>If your script was easier to read, it would
>be easier for us to help you.


I think that's the point. The "script" is incomprehensible jibberish,
written in that oh-so-common shell/awk blend that belies someone who really
doesn't know much about either language. It was, no doubt, written by
someone who is "no longer with the company" (i.e., *not* the OP).

It is, almost certainly, not about any difference between Linux and SGI,
but rather, some configuration issue. Maybe some setting in the OA
(original author)'s .profile or something on the SGI machaine that is
necessary for it to run.

In any case, without some idea of what the "input" function is (and my
reading is that it *is* defined somewhere - but you'd have to trace out the
entire path of all the shell variables and stuff to find it), analysis is
impossible.

Matt

2005-12-02, 8:51 pm


Zeppyjnr wrote:
> I run the program by pasting the following;
>
> set funiq=/file.spin
> set OFL=/file_seq_link_spin5.lst
> set OFF=/file_seq_frag_spin5.lst
> set OS=/tmp.spin
> set fambg="/empty.txt"
> set fseq=/file.seq
>
> /asd/asdafsa/awk/seq_link_un.awk spin_table="$funiq $fambg" dltca=0.3 \
> dltcb=0.4 dltco=0.3 sequence_name=$fseq fspin=$OS empty.txt | tee $OFL
> /asd/asdafsa/awk/linkunq.awk debug=1 minlen=1 fout=$OFF.frag \
> linkflag=1 ignoreamb=1 printall=1 $OFL | tee $OFF
> date
> exit
>
>
> into a shell and the first few lines of the program seq_link_un.awk
> are:
>
> #!/usr/bin/awk -f
> # dltcb=0.5
> # dltca=0.3
> # dltco=0.3
> # dlth=0.03
> # dltn=0.3
> # fspin="seq_link_un.lst"
> # showtype = show residue type flag [1]
> # showlink = show spin link flag [1]
> # typedlt = residue type limits +- delta [1]
> # linkfunpower = Power to be used on the link deviation function [1]
> # linkshift = shift on link function return value [0]
> # make line numbering for Felix dba sequential
> #
> BEGIN {
> a_tl[1]=50.0; a_tu[1]=55.0; b_tl[1]=16.0; b_tu[1]=22.0; n_t[1]="A"
> ### Get process number to open unique shell file
> "echo $$" | getline workfile
> workfile = workfile ".tmp"
> workfile1 = workfile "1"
> system("echo " workfile " temporary file for seq_link_un.awk >"
> workfile)
> getline i < workfile
> ### get parameters
> if(dltcb=="") dltcb=0.5
> if(dltca=="") dltca=0.3
> if(dltco=="") dltco=0.3
> if(dlth=="") dlth=0.03
> if(dltn=="") dltn=0.3
> if(fspin=="") fspin="seq_link_un.spin"
> if(showtype=="") showtype=1
> if(showlink=="") showlink=1
> if(typedlt=="") typedlt=1
> if(linkfunpower=="") linkfunpower=1
> if(linkshift=="") linkshift=0
> if(spin_table == "")spin_table=input(workfile,"Spin table
> name","")
> if(sequence_name == "")sequence_name=input(workfile,"Sequence
> file name","")
> dba_cnt=1
> mxcol=10
>
>
>
>
> It always hangs at the line if(spin_table ==
> "")spin_table=input(workfile,"Spin table name","")
>
> Any suggestions?
>
> Cheers
>
> Ben



Could it be that your in csh on your SGI and bash on your linux box?
'set' is pretty different from csh to *sh.

Try posting some sample input and then your expected output. Maybe
this convoluted script could be rewritten with more elegance.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com