Operating System - HP-UX
1829965 Members
2464 Online
109998 Solutions
New Discussion

UNIX script running from a different directory.

 
SOLVED
Go to solution
Jeff Daigle
Advisor

UNIX script running from a different directory.

The attached script runs fine from my directory (/home/ID123/scripts/monitor.sh). But, when I try to run it from another directory (/swift/scripts/monitor.sh) I get this error:
ksh: monitor.sh: not found

Also, to me it looks like the permissions are ok because in both places it reads like this:
-rwxrwxrwxx

What do I need to do to run this script from the other directory?
Thanks so much in advance,Jeff



5 REPLIES 5
Joseph C. Denman
Honored Contributor
Solution

Re: UNIX script running from a different directory.

Looks like the shell is not able to see monitor.sh.

Try this:

cd /swift/scripts
touch test (Make sure dir perm)
rm test (get rid of the test)
ll monitor.sh (make sure file is there)
If all work ok
./monitor.sh (. may not be in your path)

...jcd...
If I had only read the instructions first??
Jerry Zhang
Frequent Advisor

Re: UNIX script running from a different directory.

When you invoke this script from another directory, make sure you give full path the scripts resided in. For example,
/swift/scripts/monitor.sh
Sachin Patel
Honored Contributor

Re: UNIX script running from a different directory.

Hi Jeff,
This is not big problem just path problem.
Copy your monitor.sh script to /swift/scripts.
Or
#cd /swift/scripts
#/home/ID123/scripts/monitor.sh This should work because you have monitor.sh in that directory.

Sachin
Is photography a hobby or another way to spend $
someone_4
Honored Contributor

Re: UNIX script running from a different directory.

You can also put it in the directory usr/sbin and run it from any directory.

Richard
Bill Thorsteinson
Honored Contributor

Re: UNIX script running from a different directory.

I create a bin subdirectory in my home directory and
add it to the path in my .profile. Then I can access
the scripts from whichever directory I am in.

mkdir ~/bin
echo 'PATH=$PATH:~/bin >> .profile