Computing.Net > Forums > Programming > Unix If statement problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix If statement problem

Reply to Message Icon

Name: silvery59
Date: June 22, 2009 at 10:44:21 Pacific
OS: UNIX
Subcategory: Batch
Comment:

Here is a code:

I read a properties "connectionType" from file and asiign to R1
Then I print it and I see that this is "rmi"
But when I try to evaluate with if statement it does not match with the same value "rmi"
Please explain why ? What I did wrong.
I tried to delete whitespaces and it still did not work.

#! /bin/sh

R1=`grep '^connectionType=' PhoenixBatchInterface.properties|sed 's/connectionType=//'`

echo "$R1"

if [ "$R1" = "rmi" ]
then
echo RMI
else
echo NOT RMI
fi

Here is result:

rmi
NOR RMI



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: June 22, 2009 at 11:18:28 Pacific
Reply:

Make sure your $R1 variable doesn't contain any spaces at the end.


0

Response Number 2
Name: silvery59
Date: June 22, 2009 at 11:28:00 Pacific
Reply:

Thank you ! It works
Here is how I modified a code:


RADIENCE_PROTOCOL=`grep '^connectionType=' PhoenixBatchInterface.properties|sed 's/connectionType=//'|tr -d [:space:]`


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Exe file Detect and Kill Windows P...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Unix If statement problem

java switch statement problem www.computing.net/answers/programming/java-switch-statement-problem/13602.html

C# problem with if statement www.computing.net/answers/programming/c-problem-with-if-statement/18287.html

If statement question www.computing.net/answers/programming/if-statement-question/5232.html