Problem in making a script

Nils Kassube kassube at gmx.net
Mon Jul 18 16:11:02 UTC 2011


Amrit Pal Pathak wrote:
> I have problem in following code.Here i am replacing a user's enter
> password with 53 number line of a file.It is replacing with no
> problem.But the part "$db_password" is not being replaced in file
> ,only password(suppose=>123) is placed at line number 53 .

If I'm guessing right, you need a line like this in the config file:

$db_password = secret

where "secret" is the password entered by the user. If that guess is 
wrong, please give an example what the line should look like.

> echo "$db_password = $pw" >> "$TOKKK"

The shell replaces anything starting with a "$" with the contents of the 
variable of the name following the "$" sign, i.e. "$db_password" is 
replaced with the contents of the variable named "db_password". If you 
didn't set it anywhere else in the code before it is used, it is an 
empty string and the command above would append a line

 = secret

to the temporary file (again "secret" is the password entered by the 
user). If you want to start the line with the "$" sign, you should 
escape it with a backslash like this:

echo "\$db_password = $pw" >> "$TOKKK"


Nils




More information about the ubuntu-users mailing list