To run scripts


 
Thread Tools Search this Thread
Operating Systems AIX To run scripts
# 1  
Old 04-04-2008
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 ?
# 2  
Old 04-04-2008
Without assuming completeness:

- make all the paths inside the script absolute. "/x/y/z" will always refer to the same place, "./a/b/c" will not

- set the environment explicitly. You might not need that for scripts run from the commandline, but once you put the script into cron the environment is different (in this case: non-existent). Scripts which "work" on the commandline but not from cron because of this make a good part of the problems in "Shell Programming and Scripting" forum.

If you want a truly encapsulated solution you can use an external shell function for the environment and put this function into a "library". Analogous to the "PATH" variable there is a "FPATH" variable which can be set to a list of directories. It tells the shell where to search for external functions.

- all the rules of software engineering apply. Just because it is a script language does not exempt you from the necessity to document, encapsulate, strucurize, .... your code. If you wouldn't do it in a high-level language you shouldn't do it in a script either.

I hope this helps.

bakunin
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

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 ? (6 Replies)
Discussion started by: ani83_pune
6 Replies

7. 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

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