Unix If statement problem

June 22, 2009 at 10:44:21
Specs: UNIX
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" ]
echo RMI
echo NOT RMI

Here is result:


See More: Unix If statement problem

Report •

June 22, 2009 at 11:18:28
Make sure your $R1 variable doesn't contain any spaces at the end.

Report •

June 22, 2009 at 11:28:00
Thank you ! It works
Here is how I modified a code:

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

Report •

Related Solutions

Ask Question