how to run scripts....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to run scripts....
# 1  
Old 01-22-2010
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 ?
# 2  
Old 01-22-2010
Hi.

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

Code:
PATH=$PATH:.

But I would probably not do that, and use
Code:
./filetest.sh

as you originally did. It's safer than having . in your path.
# 3  
Old 01-22-2010
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
# 4  
Old 01-22-2010
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

Quote:
/home/test/abc.sh
Hope this helps you.
-Nithin.
# 5  
Old 01-22-2010
Quote:
Originally Posted by ani83_pune
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
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.

Code:
$ 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.

# 6  
Old 01-22-2010
if your shell is bash
if you create a 'bin' directory in your home path
Code:
mkdir /home/ani83/bin

Reboot and have a look at your path
Code:
$ 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.
# 7  
Old 01-22-2010
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

To run multiple scripts

Hi , Can someone help! I need a shell script to run multiple scripts by using single shell script, incase any one of the scripts fails, it should get exit and after trouble shooting if we re-execute it, it should start from the failed script (4 Replies)
Discussion started by: anniesurolyn
4 Replies

2. Shell Programming and Scripting

Run scripts in background one by one

Hello all, Can someone help with one script? I have as example 3 scripts 1.sh sleep 60 & sleep 60 & sleep 10 & sleep 80 & sleep 60 & 2.sh sleep 40 & sleep 5 & sleep 10 & sleep 70 & sleep 60 & 3.sh (2 Replies)
Discussion started by: vikus
2 Replies

3. Shell Programming and Scripting

How to run a sequence of scripts?

Assume I want to run a sequence of scripts: script0001.sh script0002.sh script0003.sh ... script0122.sh script0123.sh I only know a little Linux scripting, so the following is the best I can write for k in $(seq 1 123) do ./script${k}.sh done Of course it doesn't work... (2 Replies)
Discussion started by: zzzhhh
2 Replies

4. UNIX for Dummies Questions & Answers

Scripts can be run manually but couldn't run with cronjobs

I am from MQ/MB technology. My requirement is to display the queue manger and broker status on daily basis. If I manually run the script, it works fine and displays output. But when I have scheduled the same using cronjobs it shows only the queue manger status and not the broker status. Can... (3 Replies)
Discussion started by: Anusha M
3 Replies

5. Shell Programming and Scripting

background scripts run-help

Looking for a logic where say i have a script called parent_script which is used to call other 4 to 5 child scripts in background as.. cat parent_script # containing 65 lines 1 2 .. 35 while read child_script 36 do 37 ./child_script_name& 38 done< ${SCRIPT_LISTS} 39 40 # Need to have... (2 Replies)
Discussion started by: michaelrozar17
2 Replies

6. Shell Programming and Scripting

telnet and run scripts

Hello folks, I've got this script which connects to different boxes and executes a certain script in those locations. The following is the line from where i am trying to do this: (sleep 1; echo $USERID ; sleep 1; echo $PASSWD ; sleep 1 ; echo y ; sleep 1 ; echo "\r" ; sleep 1 ; echo "cd... (1 Reply)
Discussion started by: Rajat
1 Replies

7. AIX

To run scripts

How to run a script from any directory? Should i include any environment or wat should i start with in writing a script ? (1 Reply)
Discussion started by: rollthecoin
1 Replies

8. Shell Programming and Scripting

Can't get Cygwin to run scripts

I haven't been on a unix system in a long time and I'm trying to teach a friend unix. After looking at/testing various options cygwin seemed to be the easiest to download and install. Everything works pretty much as I recall and I even tested a small java program on it. I can't seem to get... (4 Replies)
Discussion started by: mmtemp
4 Replies

9. Shell Programming and Scripting

Run scripts within a script..

Hi all... I have several scripts of varying types (shell script, expect script, awk script) that I would like to run within 1 script.. They also take a command line argument (which it is getting successfully). The problem is, the parent script is exiting after the first script it calls is... (2 Replies)
Discussion started by: earnstaf
2 Replies

10. UNIX for Dummies Questions & Answers

How to run three scripts one after another automatically???

Hi !! How do u run three scripts one after another automatically using crontab command at some specified regular interval. Say i have three scripts A,B,C and i want to run the three scripts A followed by B followed by C. REQUIRE HELP URGENTLY Thanks in advance Arunava . (3 Replies)
Discussion started by: arunava_maity
3 Replies
Login or Register to Ask a Question