how to run scripts....

I am going to run the scripts (filetest.sh)

Its run with.....
./filetest.sh
sh filetest.sh

but not run with.....

filetest.sh ( giviing error command not found)

tell me the way how we can do it ?

Hi.

It's because the current directory (.) is not in your PATH.

PATH=$PATH:.

But I would probably not do that, and use

./filetest.sh

as you originally did. It's safer than having . in your path.

but scott when we are calling script in other script

like.....

In filetest.sh, we call abc.sh then we give directly the name...not like(./abc.sh)

so thats why i ask.....?

other wise tell me where we going to set the path

If your requirement is to call the script from another script. For example, if your script abc.sh is in /home/test folder, give the script executable permissions & call it using

Hope this helps you.
-Nithin.

Hi.

Then the directory where "abc.sh" is, is in your path when you call it - either before you call filetest.sh, or is set inside filetest.sh.

$ cat filetest.sh
abc.sh

$ cat abc.sh
echo this is abc.sh

$ filetest.sh
ksh: filetest.sh:  not found.

$ ./filetest.sh
./filetest.sh: abc.sh:  not found.

if your shell is bash
if you create a 'bin' directory in your home path

mkdir /home/ani83/bin

Reboot and have a look at your path

$ env
...
PATH=/home/ani83/bin:/bin:/sbin/:/usr/bin ...
...

There could be the 'bin' directory you created. It's a good place to put your own scripts.
But if you want the script to be shared to aother users, a good place is /usr/local/bin. But remember that you can write in that directory only as root.

This is what I do in my enterprise (OS X Sys admin). I create scripts that need to be run, and their dependencies and copy them into each client locally in a folder under /Library/Scripts/mycompany. That is where every script I ever need to call lives.

Then if I have multiple scripts, like if I have a comparison bracket with an if/then statement and it needs to call two other scripts I will just hard code the full path to my script, which is always /Library/Scripts/mycompany/name_of_script.sh

That way I can centralize it, put it in a directory owned as root. Then I can use launch agents (like cron, or init.d) run these scripts based on how I tell it to.

If I add a script to trigger a log in hook in each user's .bash_profile or in their home directory launchd looks at (this is particular to Mac OS X) it may call for other scripts in /Library/Scripts/mycompany.

It just depends on what you are trying to accomplish here.