×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

I need help with breaking down this script command by command on whatn it supposen to do!!

I need help with breaking down this script command by command on whatn it supposen to do!!

I need help with breaking down this script command by command on whatn it supposen to do!!

(OP)

michealbantor (TechnicalUser)
(OP)
26 May 18 00:46
[# command for gathering Listener Log

set v_listener_command "; echo ' Listener Log' | tr '\\n' ':'; echo '' | tr '\\n' ' ' ; lsnrctl status | grep Log | awk '{ print \$4 }' | sed 's/alert\\/log.xml/trace\\/listener.log/g' | tr '\\n' ' '; echo '-' | tr '\\n' ' ' ; du -sk `lsnrctl status | grep Log | awk '{ print \$4 }' | sed 's/alert\\/log.xml/trace\\/listener.log/g'` | awk '{ print \$1 }' | tr '\\n' ' ' ; echo '(KB)'"]

RE: I need help with breaking down this script command by command on whatn it supposen to do!!

what it is supposed to do is relatively easy

it sets an environment variable "v_listener_command" to a value determined from a sequence of shell commands.

Breakdown:
a ; (semicolon) separates commands on a single line
s | (called a pipe) passes the result from the first command to the following 'piped' command

so;

CODE --> shell

echo ' Listener Log' | tr '\\n' ':'; 
outputs a string and 'pipes' it to a tr command

CODE --> shell

tr '\\n' ':' 

tr is a 'translate' statement which replaces characters in a string.

your example replaces a newline character (\n) with a colon.

use

CODE --> shell

man 1 tr 
in a shell window for more on tr.

CODE --> shell

lsnrctl status 
Oracle database listener status request but not my department a I don't use Oracle. but the output is piped to grep for lines the word 'Log' then passes that to awk to get the 4th word/column of those lines.

Eg echo 'This is a test' | awk '{ print \$4 }' will return 'test'

[more to follow]

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: I need help with breaking down this script command by command on whatn it supposen to do!!

Meanwhile, back at the ranch;

CODE --> shell

| sed 's/alert\\/log.xml/trace\\/listener.log/g' 

sed .. is the UNIX/Linux Stream Editor, used for replacing, deleting, editing or inserting text in a text data stream or in files.

your example replaces all instances (the /g means global) of 'alert/log.xml' with 'trace/listener.log'

CODE

man sed 
for the manual pages.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: I need help with breaking down this script command by command on whatn it supposen to do!!

(OP)
You breakdown is much appreciated....thank you very much for your contribution.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close