The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   Execute .sh File (http://hintsforums.macworld.com/showthread.php?t=105821)

a1anm 09-27-2009 09:28 PM

Execute .sh File
 
Hi,

I'm trying to run an app using these instructions:

Open the Apple Terminal (located at: /Applications/Utilities) and go with the command line to the location the start.sh file is located. Then execute sh start.sh

I have used cd to navigate to the directory start.sh is stored in and tried:

sh start.sh

I ended up with this error message:

-bash: sh: command not found

Does anyone know where I'm going wrong?

Thanks.

tw 09-27-2009 10:31 PM

try ./start.sh. also, search the forum and look for Hayne's Unix FAQ, and read it. it will give you a much better grasp on the unix world.

a1anm 09-27-2009 10:59 PM

I tried that and it gave me a permission denied error.

Will look at the faq you suggested and hopefully it will shed some light.

hayne 09-28-2009 01:10 AM

It sounds like you have modified your shell's execution PATH (see the shell config section of that FAQ) and made a mistake in doing so such that "/bin" is no longer in your PATH.
To confirm this, please show us the results of the following command:

echo $PATH

a1anm 09-28-2009 12:24 PM

I get this...

alan-moores-macbook:~ alan$ echo $PATH
/usr/local/bin:/bin/sbin:/usr/bin:/usr/sbin:/usr/local/bin

Hal Itosis 09-28-2009 12:26 PM

Quote:

Originally Posted by a1anm (Post 554775)
I tried that and it gave me a permission denied error.

Is start.sh executable?
Why not list it for us?

ls -le ./start.sh
file ./start.sh

... etc.

a1anm 09-28-2009 12:30 PM

Quote:

Originally Posted by Hal Itosis (Post 554830)
Is start.sh executable?
Why not list it for us?

ls -le ./start.sh
file ./start.sh

... etc.

I'm not sure what you mean by this?

trevor 09-28-2009 12:44 PM

Hal means to go to the directory which contains start.sh, using a command similar to the one below, except with the actual path inplace of "/path/to/directory":

cd /path/to/directory

Then show us a directory listing of only the start.sh file:

ls -le ./start.sh

Then show us additional information about the file type of start.sh:

file ./start.sh

It might also be good to show us the script, assuming that it is a script:

cat ./start.sh

If the script is too long to nicely fit into this forum thread, you could alternately just show us the first few lines

head -n 20 ./start.sh

Trevor

a1anm 09-28-2009 12:55 PM

thanks for the instructions. Will do this when I get home. In the mean time this is the application if that helps:

http://mac.softpedia.com/get/Finance/OpenbravoPOS.shtml

blb 09-28-2009 01:59 PM

Quote:

Originally Posted by a1anm (Post 554827)
I get this...

alan-moores-macbook:~ alan$ echo $PATH
/usr/local/bin:/bin/sbin:/usr/bin:/usr/sbin:/usr/local/bin

You appear to have a typo here which is causing the problem; you want to have a colon between /bin and /sbin there (also, /usr/local/bin is there twice). Wherever that's being set (see the aforementioned Unix FAQ), you should instead have a path like
Code:

export PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin

Hal Itosis 09-28-2009 02:43 PM

blb and hayne appear correct. [post #5 wasn't visible (or cached?) yet, when i posted #6.]

Problem is... we can't see where the problem is.
This might show us:

/usr/bin/grep -in -C1 path ~/.[bp]* /etc/{profile,bashrc}

a1anm 09-28-2009 06:14 PM

Here is the result of that command:

Code:

/Users/alan/.bash_history-9-dscacheutil -flushcache
/Users/alan/.bash_history:10:defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
/Users/alan/.bash_history-11-svn
--
/Users/alan/.bash_history-39-sudo nano /Users/username/.bash_profile
/Users/alan/.bash_history:40:sudo nano export PATH=$PATH:/usr/local/bin
/Users/alan/.bash_history-41-cd /Users/alan/Dropbox/Portfolio/dustytunes
--
/Users/alan/.bash_history-44-svn import . http://opensvn.csie.org/dustytunes/
/Users/alan/.bash_history:45:export PATH=$PATH:/usr/local/bin
/Users/alan/.bash_history-46-svn import -m “Initial import.” /Users/alan/Dropbox/Portfolio/dustytunes
--
/Users/alan/.bash_history-259-Kind Regards,
/Users/alan/.bash_history:260:echo $PATH
/Users/alan/.bash_history-261-cd applications/openbravopos
--
/Users/alan/.bash_history-268-pico ~/.profile
/Users/alan/.bash_history:269:echo $PATH
/Users/alan/.bash_history-270-pico ~/.profile
--
/Users/alan/.bash_history-277-killall Finder
/Users/alan/.bash_history:278:echo $path
/Users/alan/.bash_history:279:echo $path
/Users/alan/.bash_history-280-pico .profile
/Users/alan/.bash_history:281:echp $path
/Users/alan/.bash_history:282:echo $path
/Users/alan/.bash_history-283-pico ~/.profile
/Users/alan/.bash_history:284:echo $path
/Users/alan/.bash_history:285:echo $path
/Users/alan/.bash_history:286:echo $path
/Users/alan/.bash_history-287-pico ~/.profile
/Users/alan/.bash_history:288:echo $path
/Users/alan/.bash_history:289:echo $PATH
/Users/alan/.bash_history-290-cd /applications/openbravopos
--
/Users/alan/.bash_history-292-./start.sh
/Users/alan/.bash_history:293:echo $PATH
/Users/alan/.bash_history:294:/usr/bin/grep -in -C1 path ~/.[bp]* /etc/{profile,bashrc}
--
/Users/alan/.bash_profile:1:export PATH=/usr/local/bin:$PATH
--
/Users/alan/.profile:1:export PATH="/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
--
/etc/profile-2-
/etc/profile:3:PATH="/bin/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
/etc/profile:4:export PATH
/etc/profile-5-

I also used the Unix FAQ guide to edit .profile. This file was empty so I added this:

export PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin

However, when I try echo $PATH it still shows as the old path:

/usr/local/bin:/bin/sbin:/usr/bin:/usr/sbin:/usr/local/bin

To edit the .profile I did this:

1. Edit your ~/.profile file.
vi ~/.profile

2. Change path to:
export PATH="/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"

3. Save the file.
4. Quit the editor.
The change takes effect immediately.

5. Check it with
echo $PATH

Thanks!

blb 09-28-2009 07:54 PM

If your .profile appears to be ignored, it's usually because you have a higher-priority dotfile which bash uses instead. Look for ~/.bash_profile or ~/.bash_login and check to see if PATH is being set there. If so, correcting that missing colon will probably get things right.

a1anm 09-28-2009 08:06 PM

thanks!!

Had a .bash_profile

Got rid of the line in that file which was setting the execution path and everything is good now. Got the app up and running.
:)

a1anm 09-28-2009 08:12 PM

one more question. Is it possible to create a shortcut icon on my desktop which would launch terminal and execute start.sh?

Rather than having to do this normally?

Edit: figured it out. Used applescript and this code:

tell application "Terminal"
activate
do script "cd /applications/openbravopos"
do script "sh start.sh" in window 1
end tell

Hal Itosis 09-28-2009 10:29 PM

Well... there are many ways around the [original] problem.
However, the actual *source* of this error appears to be inside /etc/profile...

Quote:

Originally Posted by a1anm (Post 554900)
/etc/profile-2-
/etc/profile:3:PATH="/bin/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
/etc/profile:4:export PATH
/etc/profile-5-

Which OS version are you running anyway?
From the looks of things, my guess is 10.4.x.
Here is a proper /etc/profile for (a stock) Tiger:

Code:

# System-wide .profile for sh(1)

PATH="/bin:/sbin:/usr/bin:/usr/sbin"
export PATH

if [ "${BASH-no}" != "no" ]; then
        [ -r /etc/bashrc ] && . /etc/bashrc
fi

EDIT: you probably should fix that. [there's no telling what else (other than your own shell environment) may depend on it.]

a1anm 09-28-2009 10:33 PM

I'm running snow leopard.

Hal Itosis 09-28-2009 10:44 PM

Quote:

Originally Posted by a1anm (Post 554936)
I'm running snow leopard.

That's a mighty ancient-looking (not to mention funky) profile.

Let's see the whole thing with...

cat /etc/profile

May as well list it too...

ls -l /etc/profile

a1anm 09-28-2009 11:10 PM

alan-moores-macbook:~ alan$ cat /etc/profile
# System-wide .profile for sh(1)

PATH="/bin/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
export PATH

if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi


alan-moores-macbook:~ alan$ ls -l /etc/profile
-r--r--r-- 1 root wheel 172 Feb 20 2009 /etc/profile

Hal Itosis 09-29-2009 12:23 AM

That's pretty strange... because it looks like a mangled Tiger profile. I don't have Snowy yet... but in Leopard, Apple went with the path_helper script to build the $PATH variable:
Code:

$ cat /etc/profile
# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
        eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
        [ -r /etc/bashrc ] && . /etc/bashrc
fi

$ ls -l /etc/profile
-r--r--r--  1 root  wheel  189 Sep 23  2007 /etc/profile

[maybe Snowy has reverted to the Tiger method?]. ANYONE here got 10.6? -- please post the proper profile!

Anyway, there's no denying the "/bin/sbin:" in your profile there [post #19] is the bug.

Hal Itosis 09-29-2009 01:58 PM

Quote:

Originally Posted by Hal Itosis (Post 554944)
ANYONE here got 10.6? -- please post the proper profile!

No one else reading this has Snow Leopard?
[tried finding it on the web, but no luck yet]

blb 09-29-2009 03:38 PM

/etc/profile on my 10.6.1 machine is identical to your 10.5 version...

Hal Itosis 09-29-2009 03:57 PM

Quote:

Originally Posted by blb (Post 555011)
/etc/profile on my 10.6.1 machine is identical to your 10.5 version...

Ah-ha... therefore that file on a1anm's machine may be the result of an upgrade procedure gone bad or some poorly written software install by a 3rd-party perhaps...

EDIT: stuff like that bothers me... it makes one wonder what else is florfed, that isn't apparent as yet.


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

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.