Operating System - HP-UX
1848642 Members
7202 Online
104034 Solutions
New Discussion

Re: unix scripting - understanding read_param

 
Derek Brown
Frequent Advisor

unix scripting - understanding read_param

Please see the attached unix script. It copies oracle redo logs from our production machine to the contingency machine every 15 minutes.

My boss has asked me to look at it and understand it as I may soon have to support it. I've done some shell scripting in the past so I'm not a novice; having said that I'm no expert either.

The script makes use of something called 'read_param'. My question is this : what is read_param and where is it defined ? By putting set -x at the start of the script I can see that it does what it says on the tin i.e. it reads a parameter. I can see that it reads the value of LOGHOME (for example) as /var/alexbkup. Fair enough, but I've looked until I'm blue in the face to find where read_param is defined. This is where I've looked so far :

Is it a unix command ?
/etc/profile
$HOME/.profile
aliases
$HOME/.kshrc
Variables within the script
Functions within the script

I can't see it defined anywhere. My guess is I'm missing something really obvious. If any of you guys can help I'd be most appreciative. Thanks
6 REPLIES 6
Peter Godron
Honored Contributor

Re: unix scripting - understanding read_param

Hi,
there seem to be some sort of eval equivalent going on.

Search in your PATH:
"/bin:/usr/bin:/usr/local/bin:/opt/backups/bin"
James R. Ferguson
Acclaimed Contributor

Re: unix scripting - understanding read_param

Hi Derek:

Your 'read_param' is an external script or binary that returns a value to the calling script.

For example:

LIMIT=$(read_param FS_THRESHOLD)

...set the value of LIMIT to whatever 'read_param' makes it based on the key FS_THRESHOLD.

It would be clearer and much cleaner (security-wise) if the references were made with an absolute path rather than relying on "." being in the user's path.

Regards!

...JRF...
Peter Nikitka
Honored Contributor

Re: unix scripting - understanding read_param

Hi,

since '.' is NOT in the PATH set by the script:
export PATH="/bin:/usr/bin:/usr/local/bin:/opt/backups/bin"

... and is not a std-command either, you'll have to look into
/usr/local/bin
/opt/backups/bin
for file called 'read_param'.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
James R. Ferguson
Acclaimed Contributor

Re: unix scripting - understanding read_param

Hi (again):

> Peter N. wrote: since '.' is NOT in the PATH set by the script:

Yes, I totally missed the fact the script sets its own PATH as opposed to inheriting it. In fact, this is good technique. Examine the directories Peter noted for the 'read_param' entity.

Regards!

...JRF...
Derek Brown
Frequent Advisor

Re: unix scripting - understanding read_param

Thanks guys. Problems solved now.
I want a kick up the behind for not spotting this myself. read_param was simply a script in /opt/backups/bin
Dennis Handly
Acclaimed Contributor

Re: unix scripting - understanding read_param

>I want a kick up the behind for not spotting this myself.

If you do a "whence -v", it will tell you what the shell thinks it is.