LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-26-2010, 02:44 PM   #1
sang_froid
Member
 
Registered: Oct 2006
Posts: 179

Rep: Reputation: 15
shell script problem


Hi

I have a script from which i want to disable unwanted services. I wanted to have the list of unwanted services in the same script file. I tried the following, but it is not working...How do I mention list of services in the same file and still make the script work ?

Code:
#/bin/bash
#List of services, modify list between SERVICES tag
service_list=$(cat <<SERVICES
acpid
apmd
avahi-daemon
avahi-dnsconfd
bluetooth
conman
cups
dnsmasq
dund
gpm
hidd
ip6tables
irda
netconsole
netfs
NetworkManager
SERVICES)

for service in `echo $service_list`;
do
        echo "Disabling service $service";
        /etc/rc.d/init.d/$service stop;
        echo " ";
done;
When I run, it doesn't work
 
Old 01-26-2010, 02:53 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Doesn't work is not a good description of what happens. If you create the list like this at least your list will be correct.

Code:
service_list="acpid \
apmd \
avahi-daemon \
avahi-dnsconfd \
bluetooth \
conman \
cups \
dnsmasq"
Then the for statement:

Code:
for service in $service_list
do
        echo "Disabling service $service";
        /etc/rc.d/init.d/$service stop;
        echo " ";
done
Next time run your script with sh -x yourscript to see excatly where it goes wrong.

jlinkels
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script Problem pstewart726 Programming 6 09-17-2009 02:41 AM
shell script problem bondoq Linux - Newbie 4 07-02-2006 06:31 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Shell script problem maringat Linux - Software 5 07-25-2005 05:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:37 PM.

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
Open Source Consulting | Domain Registration