Moving my AWK script from SGI to LINUX - awk

This is a discussion on Moving my AWK script from SGI to LINUX - awk ; 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 ...

+ Reply to Thread
Results 1 to 9 of 9

Moving my AWK script from SGI to LINUX

  1. Default Moving my AWK script from SGI to LINUX

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

    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!


  2. Default Re: Moving my AWK script from SGI to LINUX

    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?


  3. Default Re: Moving my AWK script from SGI to LINUX

    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


  4. Default Re: Moving my AWK script from SGI to LINUX



    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.

  5. Default Re: Moving my AWK script from SGI to LINUX

    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?


  6. Default Re: Moving my AWK script from SGI to LINUX


    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.

  7. Default Re: Moving my AWK script from SGI to LINUX

    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.

  8. Default Re: Moving my AWK script from SGI to LINUX

    In article <3v8r6eF14ogu5U1@individual.net>,
    =?ISO-8859-1?Q?J=FCrgen_Kahrs?= <Juergen.KahrsDELETETHIS@vr-web.de> wrote:
    >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.


    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), ****ysis is
    impossible.


  9. Default Re: Moving my AWK script from SGI to LINUX


    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.


+ Reply to Thread

Similar Threads

  1. executing linux shell script from within c++.net
    By Application Development in forum c++
    Replies: 1
    Last Post: 07-23-2007, 09:25 AM
  2. moving script to remote server
    By Application Development in forum Javascript
    Replies: 0
    Last Post: 01-28-2007, 03:11 PM
  3. Replies: 2
    Last Post: 11-15-2006, 06:06 PM
  4. Using igawk as the interpreter of a script on Linux
    By Application Development in forum awk
    Replies: 5
    Last Post: 01-12-2006, 04:16 AM
  5. OT - moving individual mails (mbox) via script
    By Application Development in forum Mutt
    Replies: 5
    Last Post: 11-17-2004, 12:48 AM