LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-19-2014, 08:59 AM   #1
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 15,465

Rep: Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188
Script debugging - Google Earth again


Hi, standard line 43 error again.

I have a symlink in /usr/bin pointing at /opt/google/earth/free/google-earth, and threw in a few "echo variable" lines for debugging purposes. All line numbers are the same as your script.

Code:
bash-4.3$ googleearth
/usr/bin/googleearth: line 41: cd: Line: No such file or directory
Line 42:  Line 26: /usr/bin/googleearth Line 30: /usr/bin/googleearth /opt/google/earth/free
/usr/bin/googleearth: line 43: ./googleearth-bin: No such file or directory


bash-4.3$ /opt/google/earth/free/google-earth
/opt/google/earth/free/google-earth: line 41: cd: Line: No such file or directory
Line 42:  Line 26: /opt/google/earth/free/google-earth Line 30: /opt/google/earth/free/google-earth /opt/google/earth/free
/opt/google/earth/free/google-earth: line 43: ./googleearth-bin: No such file or directory
If I wrote this script, I would feel bad about it. Has anyone got to the bottom of it? All the fancy sed and awk commands leave me a bit mystified but the thing just gets it wrong!

In looking at the above, Line 42 evidently causes it to run the 'FindPath' routine again - why I don't know. Line 42 just says
echo "Line 43: " $script_path
 
Old 10-19-2014, 11:39 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Running it as
Code:
/bin/bash -v /opt/google/earth/free/google-earth
and then looking at the output would make more sense to me.
 
Old 10-19-2014, 01:17 PM   #3
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 15,465

Original Poster
Rep: Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188
This is their script. Excuse the length. From what I see, only the three lines in red matter. The middle one calls the FindPath() routine with the argument $0. The routine does sod all (= nothing!) until the dirname $fullpath line. That truncates $0 to the directory.
Code:
#!/bin/sh
# Always run Google Earth from this shell script and not
# Google Earth directly! This script makes sure the app looks
# in the right place for libraries that might also be installed
# elsewhere on your system.
#
# Ryan C. Gordon,  Thu Jul 20 14:32:33 PDT 2006

# Function to find the real directory a program resides in.
FindPath()
{
    fullpath="`echo $1 | grep /`"
    if [ "$fullpath" = "" ]; then
        oIFS="$IFS"
        IFS=:
        for path in $PATH
        do if [ -x "$path/$1" ]; then
               if [ "$path" = "" ]; then
                   path="."
               fi
               fullpath="$path/$1"
               break
           fi
        done
        IFS="$oIFS"
    fi    
    if [ "$fullpath" = "" ]; then
        fullpath="$1"
    fi
 
    # Is the sed/ls magic portable?
    if [ -L "$fullpath" ]; then
        #               fullpath="`ls -l "$fullpath" | awk '{print $11}'`"
        fullpath=`ls -l "$fullpath" |sed -e 's/.* -> //' |sed -e 's/\*//'`
    fi
    dirname $fullpath
}

script_path=$(FindPath $0);

cd $script_path;

LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./googleearth-bin "$@"
cd $script path attempts a cd to $0 (including the filename) Needless to say, that barfs, and we go down in flames.

I want something like
script_path = "(dirname $fullpath)" but that barfs on a syntax error.

so the cd script_path is a cd to a directory, not a filename. What's the exact syntax for that?
 
Old 10-19-2014, 05:35 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Why not
Code:
#!/bin/sh --
which readlink >/dev/null 2>&1 && { cd $(dirname $(readlink -f $0)) && LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./googleearth-bin "$@"; }
exit 0
 
Old 10-20-2014, 04:06 AM   #5
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 15,465

Original Poster
Rep: Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188
:-)).

So it is possible to replace 43 lines of a script with 3 lines. As for me, it still throws up
Code:
./ge: line 3: ./googleearth-bin: No such file or directory
So I went digging. The first thing I found was that something was looking for /usr/bin/bash :-o?
Well, I just bodged past that with an otherwise harmless symlink in /usr/bin. After all, why stand on principle after coming this far?

Then ldd showed up
Code:
bash-4.3$ sudo ldd ./googleearth-bin |grep found
	libgoogleearth_free.so => not found
	libglobalnew.so => not found
bash-4.3$
So /opt/google/earth/free went onto ld.so.conf. I probably should have just added it to the LD_LIBRARY_PATH, but whatever. I added a diagnostic 'ls &&' after the first '&&' in your script, and it has definitely done a cd to /opt/google/earth/free. All the above directories back to /opt are owned root:root and perms 0755

I say all the above, because it STILL returns
Code:
/opt/google/earth/free/ge: line 3: ./googleearth-bin: No such file or directory
 
Old 10-21-2014, 01:44 PM   #6
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 15,465

Original Poster
Rep: Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188Reputation: 2188
For the record, this one is sorted.

I had the link /lib/ld-linux-so.2 --> ld-2.19.so and ldd was happy with that. Googleearth was not.

Code:
ln -s /lib/ld-2.19.so    /lib/ld-lsb.so.3
was what it wanted. Even google's script works it. The 'ls' inserted was actually a much better ploy than echoing variables.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Show Photos on Google Earth and Google Maps with*digiKam LXer Syndicated Linux News 0 10-12-2011 08:20 PM
no 'Earth' on Google earth blastradius Linux - Software 19 02-01-2009 12:05 PM
LXer: Google Maps and Google Earth KML overlays LXer Syndicated Linux News 0 10-29-2008 04:30 AM
Google Earth joint SUSE / openSUSE 2 10-27-2006 04:59 AM
Google Earth produces 'holes' in planet earth greengrocer Linux - Newbie 5 07-18-2006 10:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration