LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Calling external scripts (https://www.linuxquestions.org/questions/slackware-14/calling-external-scripts-524354/)

swampdog2002 01-31-2007 08:59 AM

Calling external scripts
 
I would like to know the best method in order to call other scripts from another script. I have an antivirus program AntiVir that has its own startup/shutdown script, and I would like to call this from rc.local. How would I go about doing this? Thanks.

swampdog2002 01-31-2007 09:05 AM

I suppose another option would be to place the startup/shutdown script for AntiVir in /etc/rc.d directory and making it executable. However, I just wanted to know for future reference how to call external scripts from another script.

tronayne 01-31-2007 09:17 AM

Just as you would execute any program (a "script" is a shell program); invoke it by name with any arguments. If you look through the files in /etc/rc.d you'll notice that they're all shell programs (and, yes, you should be executing start up and shut down from /etc/rc.d if you want things running as daemons) and they execute other programs (be they shell or C or whatever) to start and stop services.

gnashley 01-31-2007 09:25 AM

If the script you want to call is executable just call it by its' name. Otherwise you can use 'sh script_name'. There are other ways: source, '.' and exec.
Be sure to supply the full path to the script if it is not in your path.

Alien Bob 01-31-2007 01:54 PM

Quote:

Originally Posted by swampdog2002
I suppose another option would be to place the startup/shutdown script for AntiVir in /etc/rc.d directory and making it executable. However, I just wanted to know for future reference how to call external scripts from another script.

Merely placing a script in /etc/rc.d and making it executable won't make Slackware run it automatically - you will still have to add it to rc.local.

A good way which also checks the executable status of your script would be to add these lines for a script called "rc.antivir:
Code:

if [ -x /etc/rc.d/rc.antivir ]; then
  # echo "Starting AntiVirdaemon:  /etc/rc.d/rc.antivir start"
  /etc/rc.d/rc.antivir start
fi

Eric


All times are GMT -5. The time now is 07:16 AM.