LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices


Reply
  Search this Thread
Old 01-20-2004, 02:37 AM   #1
twentymil
LQ Newbie
 
Registered: Jan 2004
Location: Netherlands
Distribution: AIX, Rehat 9
Posts: 3

Rep: Reputation: 0
Can somebody help me with a ksh script?


Can somebody help me with a ksh script.

A.check if named is running.
Lssrc –s named

B.stop named daemon
stopsrc –s named

C.uncomment named in /etc/rc.tcpip for starting automaticaly after a system reboot.


D.remove named.boot file
rm /etc/named.boot

E.remove files in a directory /usr/local/tcpip/*
rm /usr/local/tcpip/*



I have to do this on 30 systems.
And a script would be helpful.
 
Old 01-20-2004, 03:01 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Create a script and a separate command file called fnames.
Edit fnames to look like this:
daemon1
daemon2
daemon3

Code:
#!/bin/ksh
# this is the script file
# change these for your system
protections="000"
# read the names of the deamons from fname
while read named   < fnames
do 
if lssrc –s $named     # is it running
then 
  stopsrc –s $named

  #uncomment named in /etc/rc.tcpip for starting automaticaly after a system reboot.
  cat /etc/rc.tcpip | sed [s/# $named/$named/g] > _tmp.tmp
  mv _tmp.tmp /etc/rc.tcpip
  chmod $prot /etc/rc.tcpip
  rm -f /etc/"$named".boot
fi 
done

 # remove files in a directory /usr/local/tcpip/*
rm -f  /usr/local/tcpip/*
unset IFS   # just in case someone changes this script not work she-bang
exit
NB: CHECK THIS SCRIPT FIRST!!!!!!

Last edited by jim mcnamara; 01-20-2004 at 03:03 PM.
 
Old 01-20-2004, 03:30 PM   #3
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
If the named has been uncommented in rc.tcpip, how has it been starting?

Code:
#!/bin/ksh

TCPFILE="./rc.tcpip"

lssrc -s named | grep active

if [ $? -eq 0 ]; then
   ACTVIE=1
   stopsrc -s named
else
   ACTIVE=0
fi

# Remove hash in named in rc.tcpip
NAMED=`cat $TCPFILE | grep named | cut -d' ' -f-2`
REP=`echo $NAMED | sed 's/^#//'`

cat $TCPFILE | sed "s@$NAMED@$REP@" > $TCPFILE.new
chmod 777 $TCPFILE
mv $TCPFILE.new $TCPFILE
chmod 774 $TCPFILE
 
rm /etc/named.boot
rm /usr/local/tcpip/*
 
Old 01-20-2004, 03:31 PM   #4
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
beat me to it.
 
Old 01-20-2004, 03:39 PM   #5
twentymil
LQ Newbie
 
Registered: Jan 2004
Location: Netherlands
Distribution: AIX, Rehat 9
Posts: 3

Original Poster
Rep: Reputation: 0
"if the named has been uncommented in rc.tcpip, how has it been starting?"

sorry guys , my english is not that good


But you guys know what I meant.


I want to prevent named from starting again after a system reboot.!


Thanks for the help on the script.
 
Old 01-20-2004, 04:14 PM   #6
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Quote:
I want to prevent named from starting again after a system reboot.!
Read your post wrong. My script was attemping to remove a comment from the file. This replacement will add it.

Code:
REP=`echo $NAMED | sed 's/^/#/'`
 
Old 01-21-2004, 03:10 AM   #7
twentymil
LQ Newbie
 
Registered: Jan 2004
Location: Netherlands
Distribution: AIX, Rehat 9
Posts: 3

Original Poster
Rep: Reputation: 0
thanks
 
Old 01-21-2004, 09:55 AM   #8
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
I read it wrong as well - my script will remove comments
 
  


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
gpg from ksh script Risc91 AIX 2 05-11-2005 10:45 AM
ksh math script SeT Programming 10 10-13-2004 08:06 AM
ksh directory comparison script SeT Programming 4 08-30-2004 11:57 AM
ksh script problem pldobs Programming 2 12-24-2003 11:38 PM
KSH script AquamaN Programming 2 12-08-2003 11:34 AM

LinuxQuestions.org > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 12:39 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
Open Source Consulting | Domain Registration