LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to close 'else' statement block in bash script (https://www.linuxquestions.org/questions/linux-general-1/how-to-close-else-statement-block-in-bash-script-253722/)

servnov 11-11-2004 02:33 PM

how to close 'else' statement block in bash script
 
if (a=b)
xxxxxx
xxxxxx
fi
else
xxxx
xxxx

how do i close the else block? with esle??

thanks.

SirSlappy 11-11-2004 02:48 PM

the else is nested between the if and fi

perfect_circle 11-11-2004 02:55 PM

something like that:

if (a=b)
xxxxxx
xxxxxx
else
xxxx
xxxx
fi

servnov 11-11-2004 02:58 PM

sweet. I feel stupid not to think of that. thanks.

servnov 11-11-2004 03:00 PM

Is there a way to scan for input from user (stdin) is a bash script.

for example

echo "press y/n to answer"

scan $ans

zhangmaike 11-11-2004 03:08 PM

Code:

read ans
Reads one line from stdin and stores it in ans. Hope that helps.

NOTE: Don't say $ans. $ans replaces itself with the value stored in ans. If, for example, $ans contained "foo", "read $ans" would be equivalent to saying "read foo" which would read one line from standard input and store it in the environment variable foo.

perfect_circle 11-11-2004 03:13 PM

read or download
Advance Bash - Scripting Guide
really nice e-book, contains everything

servnov 11-11-2004 04:12 PM

thanks.

SirSlappy 11-11-2004 10:44 PM

Here's a bash program I wrote that you might like..

It has examples of both things you want to do..


Mod Edit: Link Removed

I wrote that program to take a list of MACs that have no associated IP I steal using Kismet from a wifi network with MAC filtering on and use that list to change my wifi mac address to "steal" and IP. It's useful :-P



XavierP 11-12-2004 03:53 PM

SirSlappy, reread the Rules - LQ does not condone or encourage cracking.


All times are GMT -5. The time now is 05:16 AM.