I need to write a sed that replaces the value of all environment variables that have PASS in the name with ***** . I have a log file who prints the value of all environment variables ,including those who hold passwords. In the name of these variables I found always the PASS string, ex: OP_ORA_PASS, OP_DSU_PASS,etc.
What I did until now is the next sed :
sed 's/'"$OP_ORA_PASS"'/******/g;s/'"$DSU_ORA_PASS"'/******/g'
I need an improvment so that the sed will check and replace all the variables with PASS in the name,kind of $*_PASS.
Please provide an example of your current logfile; otherwise, we're likely to miss a corner case.
Also, you say you're replacing the values of those variables, but it looks like you're just changing the name to "*****". So an example of ideal output from your logfile snippet would be appreciated, too.
If I understand you right, you are going to add some filter into the print-env-var-script?!
If so, (assuming the environment printed out with variable names) you coud 'sed' for any line with substring 'PASS=' and replase following with '*****':
- so, it's remembering as \1 a beggining of a string with 'PASS=' and replace that string with the remembered \1 part and '*****'
The same pipe you can add in command of executing the script; so it will filtering the script's output.
If you do not have the variable's names (seems unbelievable), you can get all *PASS variables into a file or local variables and filtering printout in the way you already have, using retrieved values.
. (By the way, having a variables in sed-command part it is better to use:
... sed "commands" file
. ( - IMHO) )
For local variable: (I've used '*NAME' variables)
For file:
Thank you Alex for the examples, its exactly what I needed.
I used sed 's/^\(.*PASS=\).*/\1*****/' and it did the job.
Can you explain me what this sed contains? Or maybe give a link to read? I need to make an adaptation of it and I need to know more.
I have the following line in the log :
ORA_CONNECT_STRING=username value/password
The username name is taken from the $USERNAME variable.
How do I write the sed to change the password to *****?
sed 's/^\(.*CONNECT_STRING='"$USERNAME"'/\).*/\1*****/'
Is that correct ?
env10 is the value of $ORA_USER. Unfortunely this variable is an application-related one, and does not exist anymore when I execute the sed(after the log is writen). Because of this I get the following result :
+ sqlplus -s /****@DBL9
Thats because $ORA_USER is empty....
What I need is a sed that looks up the string : + sqlplus -S ,skips the rest until the / and then changes the string between the / and @ with *****
Hi All,
I need to understand following three environment variables and their usages in HP Unix.
_M_ARENA_OPTS
_M_CACHE_OPTS
PTHREAD_SCOPE_SYSTEM
How does these environment variables influence multi threaded applciation and how do we decide the value of these variables? Is there... (0 Replies)
Hi Everyone,
I need some help with sed and I'm totally new to it.
I have a template file with variables in it. These variables start with a '$' sign and are exactly one character long (plus the '$' sign). For example: $a, $b, etc.
Each variable should be replaced with the contents of a... (9 Replies)
1. The problem statement:
What is the mesg value set for your environment? If it is on, how would you turn off your current
session? How would you set it permanently?
3. The attempts at a solution :
Read Unix The textbook.
3rd chapter has many things like environment variables and... (5 Replies)
Hi Experts,
Need your help in understanding the commands to setup the environment variables in hp-ux.
Beleive need to use either set,setenv or export.
I am confused between above three options, when to use which option?
On command line, I have tried both set and setenv but couldn't... (1 Reply)
Hello Everyone
I need to create a script file which must append some lines to a target text file, I'm using sed for windows, the script file look like this:
{
a\
STRINGTABLE DISCARDABLE\
BEGIN\
5, 150 {a\
#define RC_SHELL, "%ID_SHELL%"\
#define RC_NAME, "%ID_NAME%"\
END
}
... (1 Reply)
Hello,
I want to writte a script that replace two character strings by two variables with the command sed butmy solution doesn't work. I'm written this: sed "s/TTFactivevent/$TTFav/g && s/switchSLL/$SLL/g" templatefile.
I want to replace TTFactivevent by the variable $TTFav, that is a... (4 Replies)
using sed to replace a specific string on a specific line number using variables
this is where i am at
grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean
grep -n Destination... (2 Replies)
hi,
I want to create a new EV(Environment Variable) through a c program and I done this thing through setenv() method. But the newly created EV is not permanent, i.e. when I exit from the program the EV also no longer lives. But I want to make it a permanent EV for the current user. Actually I... (6 Replies)
Hi!
How-to get the environment variables in GNU.
getenv() only fetches the ones that you can find under export (not the ones under declare)...
best regars .David (2 Replies)