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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

su command - can you execute a function

Status
Not open for further replies.

solvetek

Programmer
Jul 17, 2001
12
US

The su command changes user credentials to those of the root user or
to the user specified by the Name parameter, and then initiates a new
session.

su - oratest -c "command text"

is it possible for the "command text" to be an inline function instead
of a command or script? Here is my code. The error I get is "ksh:
file_remove: not found."


#!/bin/ksh
##sample code
function file_remove
{
cd $1
find . -name \*.trc -mtime +$2 -exec rm {} \;
}
su - oratest "-c file_remove $ORACLE_HOME/admin/bdump 60"
 
No,
all you have to do is call a script that will have that function in it.
 
Solvetek,
The cause may be that $ORACLE_HOME is not parsing properly. You might want to experiment a bit by doing an "echo $ORACLE_HOME" within your script to see what is coming out of $ORACLE_HOME. You may have to "play" with $ORACLE_HOME by using curly brackets ({}) around it (${ORACLE_HOME}), or setting $ORACLE_HOME explicitly within your script, or something else.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top