Calling another shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calling another shell script
# 1  
Old 04-07-2009
Calling another shell script

Hi there,

I have an script reading content of a file and runs whatever command is specified there, as follows

Code:
#!/bin/bash
# Supposed to read from a file that commands are listed to be run
# when the server starts for initialization

CMD_FILE=/myScripts/startup/task2do.txt
if [ ! -e $CMD_FILE ]; then
        echo "No task file found as $CMD_FILE!" >&2
        exit 1
fi

grep -v ^# $CMD_FILE| while read line; do
       . $line
done

echo "All tasks been done!"
exit 0

I tried to source/call directly and it's working fine however, if the command that it is supposed to execute ends with &,it doesn't go through all the commands sequentially. Could you please tell me how should I write this code that even if the command it's going to execute is like a simple while-sleep deamon written.

Many thanks,
# 2  
Old 04-07-2009
Why not just run the task2do.txt file?
Code:
# bash $CMD_FILE

or:
Code:
# chmod 500 $CMD_FILE 
# $CMD_FILE

?
# 3  
Old 04-07-2009
Thanks Tony, sounds I am really simple. but I don't know why I was trying to make it hard! perhaps lack of experience! many thanks dude!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling webservice from shell script

Hi , i am invoking webservice from shell script and it is getting hitting server but unable to get the param values. here my script like this: s is variable s=test curl --data "param=$s" url now hittng server , but param is empty. just i want param value as string even I want for... (0 Replies)
Discussion started by: kk123
0 Replies

2. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

3. Shell Programming and Scripting

calling a shell script present on another server using perl script.

Hi, I am working on a sever A. I want to write a perl script to execute a shell script persent on the server B. please help me in this. thanks in advance. (3 Replies)
Discussion started by: anandgodse
3 Replies

4. Shell Programming and Scripting

How we can pass the argument when calling shell script from perl script

Can someone let me know how could I achieve this In one of per script I am calling the shell script but I need to so one thing that is one shell script call I need to pass pne argument.In below code I am calling my ftp script but here I want to pass one argument so how could I do this (e.g:... (5 Replies)
Discussion started by: anuragpgtgerman
5 Replies

5. UNIX for Dummies Questions & Answers

calling syncsort in shell script

Hi, pls, tell me how to use syncsort in shell script? if i have to sort a file, what are the syncsort commands i hav to use ? say abc.dat is my file and dt, Id are my key columns. (0 Replies)
Discussion started by: captain haddock
0 Replies

6. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

7. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

8. Shell Programming and Scripting

Calling shell functions from another shell script

Hi, I have a query .. i have 2 scripts say 1.sh and 2.sh 1.sh contains many functions written using shell scripts. 2.sh is a script which needs to call the functions definded in 1.sh function calls are with arguments. Can some one tell me how to call the functions from 2.sh? Thanks in... (6 Replies)
Discussion started by: jisha
6 Replies

9. Shell Programming and Scripting

Calling Shell Script

Hello Friends, I have bash script on unix server which i want to call from windows server. Basically i want a command line which will call this script on unix server. Any one has any idea regarding this? Help really appreciated!! Thanks, Roshni. (1 Reply)
Discussion started by: onlyroshni
1 Replies

10. Shell Programming and Scripting

Calling shell script ?

hi friends, i'm new to unix and straight away i had to start with the script files. I've a script file which gets called from a menu item on a GUI. This script file again calls .awk file, in performing some tasks , which also generates certain files. I modified the files to generate some... (1 Reply)
Discussion started by: Ravi_Kandula
1 Replies
Login or Register to Ask a Question