Results 1 to 3 of 3
Hi,
Seems funny but I am stuck at a point !!
I am wtrying to write a simple sheel script in which I assign a value to a variable from ...
- 08-04-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 6
[SOLVED] Assign Variable vaue from a File.
Hi,
Seems funny but I am stuck at a point !!
I am wtrying to write a simple sheel script in which I assign a value to a variable from a file:
The ouptput when i run this is :Code:#!/bin/bsh DIR=/home/sappel COM_FILE=$DIR/Test.txt var_1=`cat $COM_FILE` if [$var_1 = 0] then echo "This is a Primary LB" else echo "This is a secondary LB" fi
[0: not found
This is a secondary LB
Whereas the output should be "This is a Primary LB" as the value in the files is 0.
bash-2.05$ cat Test.txt
0
Please help !!Last edited by devils casper; 08-04-2008 at 12:16 PM. Reason: Added [code]....[/code] tag.
- 08-04-2008 #2
* Spelling mistake in first line. /bin/bash
* There must be Space before and after [ ].
* It should be == instead of =.
Code:#!/bin/bash DIR=/home/sappel COM_FILE=$DIR/Test.txt var_1=`cat $COM_FILE` if [ $var_1 == 0 ] then echo "This is a Primary LB" else echo "This is a secondary LB" fi
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 08-04-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 6
aahhh..Thanks Mate !! that helped


