a tricky shell problem: remove passwords from the output
a tricky shell problem: remove passwords from the output
am 23.10.2007 17:23:24 von ibodogan
I run the following to show Unix processes connected to Sybase
database using "isql" utility:
ps -ef | grep isql
and the output looks like:
appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
dbpass1 -S prd1
appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
Pdbpass2 -S prd2
I'm trying to erase the passwords from this output so that I can email
the output w/o exposing the passwords to everyone.(well it is already
exposed in ps -ef but that's whole different story..)
As you can see from the output, the password can immediately follow -P
or there can be 1 or more space between -P and password.
is there a way to remove the passwords from this output using sed or
any other practical command ?
thx in advance,
i.d.
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 17:38:34 von Stephane CHAZELAS
2007-10-23, 08:23(-07), ibodogan@hotmail.com:
> I run the following to show Unix processes connected to Sybase
> database using "isql" utility:
>
> ps -ef | grep isql
>
> and the output looks like:
>
> appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
> dbpass1 -S prd1
> appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
> Pdbpass2 -S prd2
>
> I'm trying to erase the passwords from this output so that I can email
> the output w/o exposing the passwords to everyone.(well it is already
> exposed in ps -ef but that's whole different story..)
>
> As you can see from the output, the password can immediately follow -P
> or there can be 1 or more space between -P and password.
>
> is there a way to remove the passwords from this output using sed or
> any other practical command ?
[...]
ps -ef |
sed '/isql/!d; s/\(-P[[:blank:]]*\)[^[:blank:]]*/\1xxxxx/g'
--
Stéphane
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 17:43:44 von Janis Papanagnou
ibodogan@hotmail.com wrote:
> I run the following to show Unix processes connected to Sybase
> database using "isql" utility:
>
> ps -ef | grep isql
>
> and the output looks like:
>
> appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
> dbpass1 -S prd1
> appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
> Pdbpass2 -S prd2
>
> I'm trying to erase the passwords from this output so that I can email
> the output w/o exposing the passwords to everyone.(well it is already
> exposed in ps -ef but that's whole different story..)
>
> As you can see from the output, the password can immediately follow -P
> or there can be 1 or more space between -P and password.
Only space, no tab?
>
> is there a way to remove the passwords from this output using sed or
> any other practical command ?
sed 's/-P *[^ ]*/-P ***/'
....is one possibility.
Janis
>
> thx in advance,
> i.d.
>
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 17:43:47 von ibodogan
...
>
> [...]
>
> ps -ef |
> sed '/isql/!d; s/\(-P[[:blank:]]*\)[^[:blank:]]*/\1xxxxx/g'
>
> --
> St=E9phane- Hide quoted text -
>
> - Show quoted text -
This did not work for passwords with 5-6 chars and for other
passwords, it blanks only part of password it does not delete whole
password..
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 17:48:30 von ibodogan
On Oct 23, 10:43 am, Janis Papanagnou
wrote:
> ibodo...@hotmail.com wrote:
> > I run the following to show Unix processes connected to Sybase
> > database using "isql" utility:
>
> > ps -ef | grep isql
>
> > and the output looks like:
>
> > appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
> > dbpass1 -S prd1
> > appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
> > Pdbpass2 -S prd2
>
> > I'm trying to erase the passwords from this output so that I can email
> > the output w/o exposing the passwords to everyone.(well it is already
> > exposed in ps -ef but that's whole different story..)
>
> > As you can see from the output, the password can immediately follow -P
> > or there can be 1 or more space between -P and password.
>
> Only space, no tab?
>
>
>
> > is there a way to remove the passwords from this output using sed or
> > any other practical command ?
>
> sed 's/-P *[^ ]*/-P ***/'
>
> ...is one possibility.
>
> Janis
>
>
>
>
>
> > thx in advance,
> > i.d.- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
Great this works..
yes, rare but they can use tab too.. can you also add the tab to your
solution ? thx a lot..
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 17:54:31 von Janis Papanagnou
ibodogan@hotmail.com wrote:
> On Oct 23, 10:43 am, Janis Papanagnou
> wrote:
>
>>ibodo...@hotmail.com wrote:
>>
>>>I run the following to show Unix processes connected to Sybase
>>>database using "isql" utility:
>>
>>>ps -ef | grep isql
>>
>>>and the output looks like:
>>
>>>appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
>>>dbpass1 -S prd1
>>>appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
>>>Pdbpass2 -S prd2
>>
>>>I'm trying to erase the passwords from this output so that I can email
>>>the output w/o exposing the passwords to everyone.(well it is already
>>>exposed in ps -ef but that's whole different story..)
>>
>>>As you can see from the output, the password can immediately follow -P
>>>or there can be 1 or more space between -P and password.
>>
>>Only space, no tab?
>>
>>
>>
>>
>>>is there a way to remove the passwords from this output using sed or
>>>any other practical command ?
>>
>> sed 's/-P *[^ ]*/-P ***/'
>>
>>...is one possibility.
>>
>>Janis
>>
>>
>>
>>
>>
>>
>>>thx in advance,
>>>i.d.- Hide quoted text -
>>
>>- Show quoted text -- Hide quoted text -
>>
>>- Show quoted text -
>
>
> Great this works..
Fine.
(I wonder why Stephane's solution does not work in your environment.)
>
> yes, rare but they can use tab too.. can you also add the tab to your
> solution ? thx a lot..
>
sed 's/-P[[:blank:]] *[^[:blank:]]*/-P ***/g'
Janis
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 18:01:13 von ibodogan
On Oct 23, 10:54 am, Janis Papanagnou
wrote:
> ibodo...@hotmail.com wrote:
> > On Oct 23, 10:43 am, Janis Papanagnou
> > wrote:
>
> >>ibodo...@hotmail.com wrote:
>
> >>>I run the following to show Unix processes connected to Sybase
> >>>database using "isql" utility:
>
> >>>ps -ef | grep isql
>
> >>>and the output looks like:
>
> >>>appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
> >>>dbpass1 -S prd1
> >>>appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
> >>>Pdbpass2 -S prd2
>
> >>>I'm trying to erase the passwords from this output so that I can email
> >>>the output w/o exposing the passwords to everyone.(well it is already
> >>>exposed in ps -ef but that's whole different story..)
>
> >>>As you can see from the output, the password can immediately follow -P
> >>>or there can be 1 or more space between -P and password.
>
> >>Only space, no tab?
>
> >>>is there a way to remove the passwords from this output using sed or
> >>>any other practical command ?
>
> >> sed 's/-P *[^ ]*/-P ***/'
>
> >>...is one possibility.
>
> >>Janis
>
> >>>thx in advance,
> >>>i.d.- Hide quoted text -
>
> >>- Show quoted text -- Hide quoted text -
>
> >>- Show quoted text -
>
> > Great this works..
>
> Fine.
> (I wonder why Stephane's solution does not work in your environment.)
>
>
>
> > yes, rare but they can use tab too.. can you also add the tab to your
> > solution ? thx a lot..
>
> sed 's/-P[[:blank:]] *[^[:blank:]]*/-P ***/g'
>
> Janis- Hide quoted text -
>
> - Show quoted text -
Actually your solution works with tabs too, i tested and it worked.
Her command did not work for small passwords at all.. and for others,
it replaces the first couple of characters but shows the remaining..
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 18:09:52 von Miles
On Oct 23, 10:23 am, ibodo...@hotmail.com wrote:
> I run the following to show Unix processes connected to Sybase
> database using "isql" utility:
>
> ps -ef | grep isql
>
> and the output looks like:
>
> appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
> dbpass1 -S prd1
> appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
> Pdbpass2 -S prd2
>
> I'm trying to erase the passwords from this output so that I can email
> the output w/o exposing the passwords to everyone.(well it is already
> exposed in ps -ef but that's whole different story..)
>
> As you can see from the output, the password can immediately follow -P
> or there can be 1 or more space between -P and password.
>
> is there a way to remove the passwords from this output using sed or
> any other practical command ?
>
> thx in advance,
> i.d.
The correct solution is to cat a passfile while connecting to Sybase.
Example code:
$ISQL_COMMAND -X -U$SQLUSER -P`cat "$PASSFILE"` -S$SERVER -w255 << !
!
Miles
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 18:36:56 von Michael Tosch
Miles wrote:
> On Oct 23, 10:23 am, ibodo...@hotmail.com wrote:
>> I run the following to show Unix processes connected to Sybase
>> database using "isql" utility:
>>
>> ps -ef | grep isql
>>
>> and the output looks like:
>>
>> appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
>> dbpass1 -S prd1
>> appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
>> Pdbpass2 -S prd2
>>
>> I'm trying to erase the passwords from this output so that I can email
>> the output w/o exposing the passwords to everyone.(well it is already
>> exposed in ps -ef but that's whole different story..)
>>
>> As you can see from the output, the password can immediately follow -P
>> or there can be 1 or more space between -P and password.
>>
>> is there a way to remove the passwords from this output using sed or
>> any other practical command ?
>>
>> thx in advance,
>> i.d.
>
> The correct solution is to cat a passfile while connecting to Sybase.
>
> Example code:
> $ISQL_COMMAND -X -U$SQLUSER -P`cat "$PASSFILE"` -S$SERVER -w255 << !
> !
>
> Miles
>
>
>
Are you sure?
Isn't first the `cat "$PASSFILE"` evaluated, then the isql run with
the clear password?
--
Michael Tosch @ hp : com
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 19:23:38 von Miles
On Oct 23, 11:36 am, Michael Tosch
wrote:
> Miles wrote:
> > On Oct 23, 10:23 am, ibodo...@hotmail.com wrote:
> >> I run the following to show Unix processes connected to Sybase
> >> database using "isql" utility:
>
> >> ps -ef | grep isql
>
> >> and the output looks like:
>
> >> appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
> >> dbpass1 -S prd1
> >> appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
> >> Pdbpass2 -S prd2
>
> >> I'm trying to erase the passwords from this output so that I can email
> >> the output w/o exposing the passwords to everyone.(well it is already
> >> exposed in ps -ef but that's whole different story..)
>
> >> As you can see from the output, the password can immediately follow -P
> >> or there can be 1 or more space between -P and password.
>
> >> is there a way to remove the passwords from this output using sed or
> >> any other practical command ?
>
> >> thx in advance,
> >> i.d.
>
> > The correct solution is to cat a passfile while connecting to Sybase.
>
> > Example code:
> > $ISQL_COMMAND -X -U$SQLUSER -P`cat "$PASSFILE"` -S$SERVER -w255 << !
> > !
>
> > Miles
>
> Are you sure?
> Isn't first the `cat "$PASSFILE"` evaluated, then the isql run with
> the clear password?
>
> --
> Michael Tosch @ hp : com
I'm pretty sure. I know this won't paste well, but:
pgrep isql
UID PID PPID STIME TTY TIME CMD
monitor 2486446 3203106 0 07:01:09 pts/10 0:00 /home/sybase/
sql12.0.0/OCS-12_0/bin/isql -X -Umonitor -SNISA_SQLI
You can see where the -P should be in the output. I guess there are no
guarantees that it will never show the password, but it seems to work.
Maybe the original poster can try it out.
We run Sybase on AIX, using ksh88 and ksh93.
Miles
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 20:16:51 von Janis Papanagnou
Miles wrote:
> On Oct 23, 11:36 am, Michael Tosch
> wrote:
>
>>Miles wrote:
>>
>>>On Oct 23, 10:23 am, ibodo...@hotmail.com wrote:
>>>
>>>>I run the following to show Unix processes connected to Sybase
>>>>database using "isql" utility:
>>
>>>>ps -ef | grep isql
>>
>>>>and the output looks like:
>>
>>>>appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
>>>>dbpass1 -S prd1
>>>>appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
>>>>Pdbpass2 -S prd2
>>
>>>>I'm trying to erase the passwords from this output so that I can email
>>>>the output w/o exposing the passwords to everyone.(well it is already
>>>>exposed in ps -ef but that's whole different story..)
>>
>>>>As you can see from the output, the password can immediately follow -P
>>>>or there can be 1 or more space between -P and password.
>>
>>>>is there a way to remove the passwords from this output using sed or
>>>>any other practical command ?
>>
>>>>thx in advance,
>>>>i.d.
>>
>>>The correct solution is to cat a passfile while connecting to Sybase.
>>
>>>Example code:
>>>$ISQL_COMMAND -X -U$SQLUSER -P`cat "$PASSFILE"` -S$SERVER -w255 << !
>>>!
>>
>>>Miles
>>
>>Are you sure?
>>Isn't first the `cat "$PASSFILE"` evaluated, then the isql run with
>>the clear password?
>>
>>--
>>Michael Tosch @ hp : com
>
>
> I'm pretty sure. I know this won't paste well, but:
>
> pgrep isql
> UID PID PPID STIME TTY TIME CMD
> monitor 2486446 3203106 0 07:01:09 pts/10 0:00 /home/sybase/
> sql12.0.0/OCS-12_0/bin/isql -X -Umonitor -SNISA_SQLI
>
>
> You can see where the -P should be in the output. I guess there are no
> guarantees that it will never show the password, but it seems to work.
> Maybe the original poster can try it out.
>
> We run Sybase on AIX, using ksh88 and ksh93.
>
> Miles
>
I think Michael is right and can *not* confirm what you say; using ksh93r
the arguments are visible in the process list. Do _not_ use that pattern
if you intend to hide arguments!
Janis
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 21:39:10 von Miles
On Oct 23, 1:16 pm, Janis Papanagnou
wrote:
> Miles wrote:
> > On Oct 23, 11:36 am, Michael Tosch
> > wrote:
>
> >>Miles wrote:
>
> >>>On Oct 23, 10:23 am, ibodo...@hotmail.com wrote:
>
> >>>>I run the following to show Unix processes connected to Sybase
> >>>>database using "isql" utility:
>
> >>>>ps -ef | grep isql
>
> >>>>and the output looks like:
>
> >>>>appadm 13589 10287 0 12:11:56 pts/8 0:00 isql -w330 -U cpg_adm -P
> >>>>dbpass1 -S prd1
> >>>>appadm 17289 10287 0 12:11:56 pts/8 0:00 isql -U miso_adm -
> >>>>Pdbpass2 -S prd2
>
> >>>>I'm trying to erase the passwords from this output so that I can email
> >>>>the output w/o exposing the passwords to everyone.(well it is already
> >>>>exposed in ps -ef but that's whole different story..)
>
> >>>>As you can see from the output, the password can immediately follow -P
> >>>>or there can be 1 or more space between -P and password.
>
> >>>>is there a way to remove the passwords from this output using sed or
> >>>>any other practical command ?
>
> >>>>thx in advance,
> >>>>i.d.
>
> >>>The correct solution is to cat a passfile while connecting to Sybase.
>
> >>>Example code:
> >>>$ISQL_COMMAND -X -U$SQLUSER -P`cat "$PASSFILE"` -S$SERVER -w255 << !
> >>>!
>
> >>>Miles
>
> >>Are you sure?
> >>Isn't first the `cat "$PASSFILE"` evaluated, then the isql run with
> >>the clear password?
>
> >>--
> >>Michael Tosch @ hp : com
>
> > I'm pretty sure. I know this won't paste well, but:
>
> > pgrep isql
> > UID PID PPID STIME TTY TIME CMD
> > monitor 2486446 3203106 0 07:01:09 pts/10 0:00 /home/sybase/
> > sql12.0.0/OCS-12_0/bin/isql -X -Umonitor -SNISA_SQLI
>
> > You can see where the -P should be in the output. I guess there are no
> > guarantees that it will never show the password, but it seems to work.
> > Maybe the original poster can try it out.
>
> > We run Sybase on AIX, using ksh88 and ksh93.
>
> > Miles
>
> I think Michael is right and can *not* confirm what you say; using ksh93r
> the arguments are visible in the process list. Do _not_ use that pattern
> if you intend to hide arguments!
>
> Janis
If you google for "sybase faq hiding password", take the first result,
http://www.isug.com/Sybase_FAQ/ASE/section4.html.
Script #3, looks very similar:
#!/bin/sh
umask 077
isql -Umyuserid -Smyserver <<-endOfIsql
mypassword
use mydb
go
sp_who
go
endOfIsql
Simply move the password inside the here document.
Miles
Re: a tricky shell problem: remove passwords from the output
am 23.10.2007 22:55:46 von Janis Papanagnou
Miles wrote:
> On Oct 23, 1:16 pm, Janis Papanagnou
> wrote:
>>Miles wrote:
>>>On Oct 23, 11:36 am, Michael Tosch
>>> wrote:
>>>>Miles wrote:
>>
>>>>>$ISQL_COMMAND -X -U$SQLUSER -P`cat "$PASSFILE"` -S$SERVER -w255 << !
>>>>>!
>>
>>>>Are you sure?
>>>>Isn't first the `cat "$PASSFILE"` evaluated, then the isql run with
>>>>the clear password?
>>
>>>You can see where the -P should be in the output. I guess there are no
>>>guarantees that it will never show the password, but it seems to work.
>>>Maybe the original poster can try it out.
>>
>>I think Michael is right and can *not* confirm what you say; using ksh93r
>>the arguments are visible in the process list. Do _not_ use that pattern
>>if you intend to hide arguments!
>
> If you google for "sybase faq hiding password", take the first result,
> http://www.isug.com/Sybase_FAQ/ASE/section4.html.
>
> Script #3, looks very similar:
> #!/bin/sh
> umask 077
> isql -Umyuserid -Smyserver <<-endOfIsql
> mypassword
> use mydb
> go
> sp_who
> go
> endOfIsql
>
> Simply move the password inside the here document.
The seven scripts from your link above and the preceeding example
from that page differ from your suggestion on top of this posting,
which Michael and I were commenting on. To repeat: don't do that.
Janis