Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to specify a particular executable script/file.

Status
Not open for further replies.

motoslide

MIS
Oct 30, 2002
764
US
Is there an environment setting to force selection of a particular executable which may be later in the PATH than an identically named executable?

I know that sounds vague. Let me explain by example.

Say you have a script called "who" in /usr/local/bin, but there is also the built-in command in /bin. Your PATH is:
/bin;/usr/bin;/usr/local/bin (to make this simple).
Is there a way to force the shell to run /usr/local/bin/who instead of /bin/who without specifying the full pathname?
 
With an alias ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That appears to work in ksh, but our application is running in sh, and it doesn't appear to support the "alias" function. I'll see if we can adjust to ksh instead.

Thanks for the lead. I knew there was something like that available.
 
In legacy bourne shell you may try a function:
who() { /usr/local/bin/who $@; }

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The function works for my bourne shell, but doesn't appear to get passed to subsequent shells.

Is there a way to "EXPORT" a function in the same manner you can an environment variable?
 
In the .profile:
who=/usr/local/bin/who export who

In your shell scripts:
${who:=/bin/who} am i

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top