changing a password held in a file -from a script
am 31.01.2008 18:27:25 von peter sands
Hi,
I need to change the password of a application user that is held in a
file called .pass ( shown below), within my script, my script gets
passed either PA_SYBASE,JA_SYBASE,PD_SYBASE plus the new password,
from that I need to , I guess use sed change it.
If I get passed user: PA_SYBASE, I then need to change the entry in
the file p3erth to the new password. I know how to get the correct
line, but I am stuck on how to change the password entry.
Thanks, Pete.
PA_SYBASE_PASSWD=p3erth
JA_SYBASE_PASSWD=jelli0
PD_SYBASE_PASSWD=bron1a
Re: changing a password held in a file -from a script
am 31.01.2008 19:56:29 von PK
peter sands wrote:
> Hi,
> I need to change the password of a application user that is held in a
> file called .pass ( shown below), within my script, my script gets
> passed either PA_SYBASE,JA_SYBASE,PD_SYBASE plus the new password,
> from that I need to , I guess use sed change it.
> If I get passed user: PA_SYBASE, I then need to change the entry in
> the file p3erth to the new password. I know how to get the correct
> line, but I am stuck on how to change the password entry.
>
> Thanks, Pete.
>
> PA_SYBASE_PASSWD=p3erth
> JA_SYBASE_PASSWD=jelli0
> PD_SYBASE_PASSWD=bron1a
For example (if the file is as shown):
#!/bin/bash
user="${1}_PASSWD"
newpass="${2}"
sed "s/^${user}=.*$/${user}=${pass}/" .pass