Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 11:18 on June 26, 2006


[Help] simple shell problems

Today, quite a number of shells, it was the freebsd bash, a very simple book on the code looks right, but not always enforced.
As follows :

#!/usr/local/bin/bash
WORD= "tele"
Echo "what 's your name"
Read NAME
Echo
Echo "Helllo, $NAME, please guess the word.Your"
Echo "choices are iguana, tele, slurp"
Read GUESS

$GUESS=$WORD [If]
Then
Echo "You are correct!"
Else
Echo "Incorrect!"
Fi

But my words no matter what input, the final show You are always correct!
Where does the wrong ah?

[Help] simple shell problems

$GUESS=$WORD $GUESS -eq $WORD Read :

[Help] simple shell problems

# If [the attention of] box $GUESS ====== $WORD

[Help] simple shell problems

Thank you two spaces, a laughing stock

[Help] simple shell problems

If not variable, direct and characters, such as : $GUESS ====== "a", it seems wrong on the implementation of the bar, $GUESS= "a" wrong, the book also seems wrong

[Help] simple shell problems

Attention box

[Help] simple shell problems

[code]
[ "$GUESS" = "$WORD" ][/code]

[Help] simple shell problems

$GUESS = "A", add the box, not yes.
End this to say : there are always running. : : : [9 /sh5 line : integer expression expected iguana

[Help] simple shell problems

In order to test the top : oops :
[code]
Read;[[ $REPLY ====== "a" ]]&&echo ok||echo error[/code]

[Help] simple shell problems

Error

[Help] simple shell problems

Read;[[ $REPLY= "a" ]]&&echo ok||echo error
The results ok
But written into the script, or appeared lines, it has failed to correct results

[Help] simple shell problems

-->
Sorry, no way, I have the script in order firms and the results can be correctly_

[Help] simple shell problems

#!/usr/local/bin/bash
WORD= "tele"
Echo "what 's your name"
Read NAME
Echo
Echo "Helllo, $NAME, please guess the word.Your"
Echo "choices are iguana, tele, slurp"
Read GUESS

$GUESS=$WORD [If]
Then
Echo "You are correct!"
Elif [$GUEST= "iguana"]
Then
Echo "it 's not iguana"
Elif [$GUEST= "slurp"]
Then
Echo "it 's not slurp"
Else
Echo "is not even in the list! $GUESS"
Fi

The question now is what I can import, including tele, iguana, slurp, or other arbitrary combinations of letters, procedures show it 's not iguana, in a phrase like this : before. /sh5 Line 9 : : : [iguana : integer expression expected
Things

[Help] simple shell problems

[Help] simple shell problems

Equal on both sides of the ballots also increases errors, but also what is strange information, but show no matter what the final echo of the importation of a phrase

[Help] simple shell problems

[color=red]if [$GUESS ====== $WORD ][/color]
Then
Echo "You are correct!"
[$GUEST ====== [color=red]elif "Iguana" ][/color]
Then
Echo "it 's not iguana"
[$GUEST ====== [color=red]elif "Slurp"]
[/color]then
Echo "it 's not slurp"
Else
Echo "is not even in the list! $GUESS"
Fi

[Help] simple shell problems

#!/usr/local/bin/bash
WORD= "tele"
Echo "what 's your name"
Read NAME
Echo
Echo "Helllo, $NAME, please guess the word.Your"
Echo "choices are iguana, tele, slurp"
[color=red]read GUESS[/color]

[color=red]if $GUESS = [ "$WORD" ][/color]
Then
Echo "You are correct!"
[color=red]elif $GUESS = [ "Iguana" ][/color]then
Echo "it 's not iguana"
[color=red]elif $GUESS = [ "Slurp" ][/color]then
Echo "it 's not slurp"
Else
Echo "is not even in the list! $GUESS"
Fi

I think he wanted to be above the bar Results

Note :
1 =% of the ballots,
2, elif are behind the variables should not be GUEST[/color] GUESS

[Help] simple shell problems

#!/usr/local/bin/bash
WORD= "tele"
Echo "what 's your name"
Read NAME
Echo
Echo "Helllo, $NAME, please guess the word.Your"
Echo "choices are iguana, tele, slurp"
[color=red]read GUESS[/color]

[color=red]if $GUESS = [ "$WORD" ][/color]
Then
Echo "You are correct!"
[color=red]elif $GUESS = [ "Iguana" ][/color]then
Echo "it 's not iguana"
[color=red]elif $GUESS = [ "Slurp" ][/color]then
Echo "it 's not slurp"
Else
Echo "is not even in the list! $GUESS"
Fi

I think he wanted to be above the bar Results

Note :
1 =% of the ballots,
2, elif are behind the variables should not be GUEST[/color] GUESS

[Help] simple shell problems

Sorry
Plus code plus the French did not put the transport,
Above the red font behind the incumbent, then the trip, or before then increase;

[Help] simple shell problems

#!/usr/local/bin/bash
WORD= "tele"
Echo "what 's your name"
Read NAME
Echo
Echo "Helllo, $NAME, please guess the word.Your"
Echo "choices are iguana, tele, slurp"
[color=red]read GUESS[/color]

[color=red]if $GUESS = [ "$WORD" ][/color]
Then
Echo "You are correct!"
[color=red]elif $GUESS = [ "Iguana" ][/color]then
Echo "it 's not iguana"
[color=red]elif $GUESS = [ "Slurp" ][/color]then
Echo "it 's not slurp"
Else
Echo "is not even in the list! $GUESS"
Fi

I think he wanted to be above the bar Results

Note :
1 =% of the ballots,
2, elif are behind the variables should not be GUEST[/color] GUESS



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com