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 -c command --- can you exec 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"
 
Try writing a function file(library) with all your functions in it and sourcing it: thats how they do it in C.;-)

#!/bin/ksh
. /myfunctionspathhere/
su -c file_remove $ORACLE,etc..

Also is your syntax right?
In the bourne shell:
file_remove() {
code
}

Otherwise I think tcl/expect or perl would be very good for this, maybe more code but more
flexibility too...




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top