Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-28-2011
Registered User
 

Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Scripting Issue

needing this script to shut down 1 IceS and start up another, close the 2nd one after 12 seconds and then reboot. here is what i have so far


Code:
#!/bin/bash

ShutDown() {
echo "Shutdown in progress."
wall <<ENDOFWALL
CI Shutdown has been intiated!!!!
Shutdown will occur in 30 seconds...
ENDOFWALL
sleep 18
killall ices
echo "Starting the Shutdown IceS"
ices -c-b /usr/local/etc/shutdown.conf.dist
sleep 12s
killall ices
echo "Reboot command goes here"
}

clear
echo "Are you sure you want to REBOOT the Collective Industries server? (Y/n)"
read answer
if [ $answer = Y ]
then
ShutDown

if [ $answer = n ]
then 
echo "Shutdown has been canceled"
fi
fi

Sponsored Links
    #2  
Old 01-29-2011
Scrutinizer's Avatar
mother ate her
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 5,371
Thanks: 80
Thanked 1,107 Times in 1,011 Posts
It helps if you indent the code. Then it is clear the the last fi is in the wrong place and should be put a few lines earlier. Also, any other character will result in cancellation, only "n'" will produce a message stating that the shutdown has been canceled. Also the double quotes ensure the input is handled well if someone just hits enter...


Code:
if [ "$answer" = "Y" ]; then
  ShutDown
else
  echo "Shutdown has been canceled"
fi

If you are using killall (hopefully on linux, on many other unixen killall means something very different that you probably do not want to use) then how do you kill the first en only kill the second later, seeing as killall is indiscriminate if two processes carry the same name. I would consider determining the pid and kill that or preferrably use the script that came with the application.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Scripting Issue lsudubee Shell Programming and Scripting 1 07-08-2010 02:13 PM
scripting issue mraghunandanan Shell Programming and Scripting 1 05-19-2009 06:36 AM
IP-Scripting Issue mraghunandanan Shell Programming and Scripting 3 05-08-2009 04:28 PM
Awk scripting issue hcclnoodles Shell Programming and Scripting 3 01-18-2005 08:23 AM
scripting issue moe2266 Shell Programming and Scripting 2 01-05-2005 09:32 AM



All times are GMT -4. The time now is 04:18 AM.