Menu

#472 linux startup script 'apollo' fails when awk is mawk

chado-apollo
closed
elee
Apollo (90)
5
2008-05-14
2008-05-08
ben
No

When I ran apollo, it appeared to fail to start java:

apollo.1.8.0/bin$ ./apollo
APOLLO_ROOT set to /home/ben/bioinfo/apollo.1.8.0/bin
Couldn't find JavaPath line in apollo.cfg file, trying to guess path to java...
unalias: java not found
Using version of Java in /us: /us/bin/java
Could not make a good guess about the location of Java, or JavaPath line in apollo.cfg is no good--it said /us

It appears to fail because of this part of the script:
#set the javapath to the path given by 'which java', without the bin/java
# (basically, get the path to java and trim off the last 9 characters;
# obviously, this approach won't work if you've installed java strangely,
# but java probably won't work either)
JAVAPATH=`which java | awk ' { print (substr($0,0, length($0) - 9)) } '`;

because the default awk is mawk, not gawk. This is the default on Ubuntu Hardy Heron. See the difference below:
$ which java | gawk ' { print (substr($0,0, length($0) - 9)) } '
/usr
$ which java | mawk ' { print (substr($0,0, length($0) - 9)) } '
/us

Seems to be fixed by replacing the offending line with
JAVAPATH=`which java |sed -e 's/\/bin\/java$//'`;

Discussion

  • ben

    ben - 2008-05-08

    Fixed sample file

     
  • elee

    elee - 2008-05-14

    Logged In: YES
    user_id=1323996
    Originator: NO

    Thanks for pointing this out. I didn't expect a Linux distro to default to mawk over gawk. Go figure. Anyway, mawk has a buggy implementation of substr() so the launch script has been changed to use sed instead.

     
  • elee

    elee - 2008-05-14
    • assigned_to: nobody --> gk_fan
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB