Go Back   Technibble Forums > Operating Systems > Linux

  Technibble Sponsor

Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2011, 02:06 PM
Appletax's Avatar
Appletax Appletax is offline
 
Join Date: Sep 2010
Posts: 569
Appletax will become famous soon enough
Arrow Fake daemon script not working

$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.
Reply With Quote
  #2  
Old 11-22-2011, 02:36 PM
Slaters Kustum Machines's Avatar
Slaters Kustum Machines Slaters Kustum Machines is online now
 
Join Date: Jun 2011
Location: Iowa
Posts: 1,143
Slaters Kustum Machines is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 11-22-2011, 04:30 PM
Appletax's Avatar
Appletax Appletax is offline
 
Join Date: Sep 2010
Posts: 569
Appletax will become famous soon enough
Default

The script comes directly from my Linux+ Guide to Linux Certification book
Book uses Fedora 13 I'm running 14 in VM
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 11:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Technibble.com is based out of MELBOURNE, AUSTRALIA.