Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can somebody help me with a ksh script

Status
Not open for further replies.

twenty

Technical User
Jan 19, 2004
3
NL
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


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

E.remove files in a directory /usr/local/tcpip/*
rm /usr/local/tcpip/*
 
You weren't insufficently clear but should be something like:
lssrc -s named|grep -q active
if [ $? = 0 ];then
stopsrc -s named
awk '{ if ( $0 ~ /\/usr\/sbin\/named/) { print substr($0,2) } else {print $0 }}' < /etc/rc.tcpip > /tmp/etc_rc.tcpip
cat /tmp/etc_rc.tcpip > /etc/rc.tcpip
rm /etc/named.boot
rm /usr/local/tcpip/*
fi

As you can see you wrote the script by yourself
 
for non-interactive editing you can use the following:

vi /etc/rc.tcpip <<END
:g/\/usr\/sbin\/named/s/^/#/g
^[
ZZ
END

where ^[ is entered with sequence: CTRL-V ESC


regards,m.
 
Thanks guys for the quick response.

It's realy helpful.

 
I made a mistake in C.

Tmeant that I want to place a hash in rc.tcpip to prevent named from automaticly starting after a reboot.!
 
Well in this case solution should be:
lssrc -s named|grep -q active
if [ $? = 0 ];then
stopsrc -s named
awk '{ if ( $0 ~ /#\/usr\/sbin\/named/) { print substr($0,2) } else {print &quot;#&quot;$0 }}' < /etc/rc.tcpip > /tmp/etc_rc.tcpip
cat /tmp/etc_rc.tcpip > /etc/rc.tcpip
rm /etc/named.boot
rm /usr/local/tcpip/*
fi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top