LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-31-2007, 08:59 AM   #1
swampdog2002
Member
 
Registered: Jul 2005
Distribution: Slackware 12.2, 13.0, openSUSE 11.2
Posts: 400

Rep: Reputation: 33
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.
 
Old 01-31-2007, 09:05 AM   #2
swampdog2002
Member
 
Registered: Jul 2005
Distribution: Slackware 12.2, 13.0, openSUSE 11.2
Posts: 400

Original Poster
Rep: Reputation: 33
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.
 
Old 01-31-2007, 09:17 AM   #3
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
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.
 
Old 01-31-2007, 09:25 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,897

Rep: Reputation: 577Reputation: 577Reputation: 577Reputation: 577Reputation: 577Reputation: 577
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.
 
Old 01-31-2007, 01:54 PM   #5
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 7,535

Rep: Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling shell scripts from PHP as other users Thin Programming 1 12-02-2005 08:17 AM
Cannot run scripts on my external hd eireflows Linux - Hardware 3 07-17-2005 08:57 AM
Calling external programs to FTP from C program Manish Programming 11 04-03-2005 10:53 PM
QT newbie - calling external programs squinn Programming 1 03-24-2005 10:23 AM
calling external applications in your c++ code drisay Programming 2 01-25-2005 12:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration