-1
#!/bin/bash

input=""

echo "Does a wall needs to be sent?"
read input

if [ $input="yes" ]; then
   echo "Sending message to all users"
   echo ""
else if [ $input="no"]; then
    exit
    fi
fi
echo "Is this a reboot or shutdown?"
      read input
if [ $input="reboot" ]; then
   reboot
elif [ $input="shutdown" ]; then
else
echo ""
echo "Goodbye"

closed as off-topic by jasonwryan, slm Jul 12 '14 at 3:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – jasonwryan, slm
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Among other things, you need spaces around the assignments, eg., [ $input = "yes" ]... – jasonwryan Jul 12 '14 at 3:31
  • elif dude, elif. else is for the final catch-all. – RobotHumans Jul 12 '14 at 3:31
4

That script has a bunch of issues. Here's a cleaned up version:

#!/usr/bin/env bash

input=""

echo "Does a wall needs to be sent?"
read input

if [ "$input" = "yes" ]; then
    echo "Sending message to all users\n"
elif [ "$input" = "no" ]; then
    exit
fi

echo "Is this a reboot or shutdown?"
read input

if [ "$input" = "reboot" ]; then
    reboot
elif [ "$input" = "shutdown" ]; then
    shutdown -h now
fi

echo "\nGoodbye"

Honestly though, this is still really poorly done. I would recommend using case statements parsing arguments instead of reading input.

Not the answer you're looking for? Browse other questions tagged or ask your own question.