how to extract a 2-line pattern from a file using awk, grep, etc.
1. I want to identify usernames with the same password which is a security/audit issue.
2. The audit script output tests all such connections to the server database having the same password. 3. I need to extract only the usernames that connect successfully so that these passwords can be addressed. I know how to change passwords 4. Here is a sample of the huge output file: SQL> connect AA/AA; Connected. SQL> connect B4B/B4B; ORA-28000: the account is locked Warning: You are no longer connected to ORACLE. SQL> connect CCg/CCg; ORA-01017: invalid username/password; logon denied SQL> connect Dee/Dee; Connected. SQL> connect eR/eR; ORA-28000: the account is locked Warning: You are no longer connected to ORACLE. SQL> connect Fdw2/Fwd2; ORA-01017: invalid username/password; logon denied Warning: You are no longer connected to ORACLE. SQL> connect gAMw/gAMw; Connected. 5. I would like an output file similar to this after pattern searching (i.e. only the connected usernames): SQL> connect AA/AA; Connected. SQL> connect Dee/Dee; Connected. SQL> connect gAMw/gAMw; Connected. NB: the search should have nothing to do with usernames starting with an alphabet. Much obliged, Waiting in anticipation! |
You can use: awk ' BEGIN { RS="SQL>" } ... ' and you will get the info in one line. You can use /Connected/ to find successful logins....
|
Thx Pan64.
Apologies I'm a beginner with awk. Kindly explain to me how to just get the connected usernames from the output file. By that I mean, after awk or whatever command or script, I get an output file as follows or similar: SQL> connect AA/AA; SQL> connect Dee/Dee; SQL> connect gAMw/gAMw; Tx |
something like this:
Code:
awk ' BEGIN { RS="SQL>" } _____________________________________ If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post. Happy with solution ... mark as SOLVED (located in the "thread tools") |
tx for the expanded command.
I now get the following output: SQL> connect connect SQL> connect Connected. SQL> connect connect SQL> connect connect SQL> connect connect SQL> connect Connected. SQL> connect connect instead of the three connected usernames as in my first posting? pls help! |
i guess nobody knows the answer to my question!!
or did I not not explain it well enough?? hello Q&A forum???? |
it works fine for me, so probably you mistyped something or you have a different environment. Try to replace $2 with $1 or $3 and start again....
_____________________________________ If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post. Happy with solution ... mark as SOLVED (located in the "thread tools") |
From grep's man page:
Code:
Context Line Control |
Thank u guys! $3 worked!
|
Quote:
|
All times are GMT -5. The time now is 06:49 PM. |