not able to read variable value which is sed into a file
Hello all,
I have a file test.sh in which I am reading the disk size in two systems, system1 and system2 and storing them in variables s1 and s2 then I am "sed"ing the values into the same file using commands Code:
sed "6i \server1=\"${s1}\"" -i /Server1/test.sh Code:
sed "7i \server2=\"${s2}\"" -i /Server1/test.sh But when i try to read the value of the variables server1 and server2 I get empty strings i.e. the value is null.. why so?? I know it sounds complicated but can anyone help me? Thanks in Advance :) |
would be nice to see your test.sh before and after that sed command (to check what's happened)
also you can try to add set -xv at the beginning of your script. |
code:
Quote:
|
I think you have missed the point. The sed's will alter the files called on and add the serverN=val line. Within your script, server1 and server2 variables are never set.
|
grail means this script will alter the file named test.sh. Probably this script is that one, I have no idea. But in that case the running program cannot be altered, just the file (so you need to start test.sh after that modification)
|
From what the op has said and posted this is definatly self modifying code which you cant do with bash and is a realy old fashioned and crappy way of programming. Self modifying code may have been tolerable in the past when RAM and storage space was at a premium but not on a modern system.
|
All times are GMT -5. The time now is 07:39 AM. |