|
#1
|
||||
|
||||
|
$1 refers to the first argument given when executing the shell script on
the command line #! /bin/bash if [ $1="start" ] then echo "The sample daemon has started" sleep 2 elif [ $1="stop" ] then echo "The sample daemon has been stopped" sleep 2 elif [ $1="restart" ] then echo "The sample daemon has been restarted" sleep 2 fi Running Fedora 14 The problem is that when I type service sample stop/start/restart I always am given the message "The sample daemon has started" Last edited by Appletax; 11-22-2011 at 02:12 PM. |
|
#2
|
||||
|
||||
|
Looks like the problem is you are not "asking" for input.
Try this: #! /bin/bash echo "Please enter your option: " read option_variable if [ $option_variable="start" ];then echo "The sample daemon has started" sleep 2 elif [ $option_variable="stop" ]; then echo "The sample daemon has been stopped" sleep 2 elif [ $option_variable="restart" ]; then echo "The sample daemon has been restarted" sleep 5 fi Nevermind, that doesn't work as expected either. Last edited by Slaters Kustum Machines; 11-22-2011 at 03:08 PM. |
|
#3
|
||||
|
||||
|
The script comes directly from my Linux+ Guide to Linux Certification book
Book uses Fedora 13 I'm running 14 in VM |
![]() |
| Thread Tools | |
| Display Modes | |
|
|