- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: how to call profile function
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2006 05:51 AM
тАО05-12-2006 05:51 AM
I have a function into my profile:
function lcprod01 {
export ORACLE_SID=lcprod01n1
PS1="[`hostname`*${ORACLE_SID} \${PWD}]$ "
dump
}
From the prompt I call the function just writing the name of the function. OK.
How can I call the function from inside another shell script?
This is I have a shell script wich receives a parameter with the name of the funcion and I need to call the function (accroding to the parameter of the shell script) from inside the shell script.
Example:
$ MyScript.sh ProfileFunctionName
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2006 07:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2006 03:19 AM
тАО05-15-2006 03:19 AM
Re: how to call profile function
I am afraid that nothing of both options has worked.
This is the code of my script.
#!/bin/bash
#
# Description: De la base de datos especificada, mata todas las sesiones del usuario especificado
# Parametros de entrada: $1 = nombre/referencia de la instancia
# $2 = username del usuario a matar todas sus sesiones
#
# Set ORA_HOME equivalente a $ORACLE_HOME
# Set SCP_HOME equivalente a la ruta completa donde se encuentran los cripts
#
SCP_HOME=/home/oracle/scripts
ORA_HOME=/opt/oracle/rdbms/9.2.0
ORA_USER=$2
. $HOME/.bash_profile
$1 #<- Here should call the function
sqlplus /nolog $args <
spool $SCP_HOME/sessions_to_kill.sql
select instance_name from v\$instance;
select 'alter system kill session '''||sid||','||serial#||''';' from v\$session where username='$2';
spool off
exit
EOF
And this is a sample code for the profile functions:
function lcprod01 {
export ORACLE_SID=lcprod01n1
PS1="[`hostname`*${ORACLE_SID} \${PWD}]$ "
dump
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2006 09:26 AM
тАО05-15-2006 09:26 AM
Re: how to call profile function
Your function will have another problem. It is setting PS1. But setting PS1 in a shell script will not change the value of PS1 in your login shell. The only way to set a variable in your login shell is to evaluate the assignment in your login shell.
One way to set a variable is to source the shell script. You can to that with ./myscript.sh from your login shell.
That runs myscript.sh in your login shell instead of starting a new shell process to run it.
Another way is to source the output of your script as shell commands. That approach is taken by the resize command.
$(resize)
says to evaluate the variable assignment commands that resize write to its stdout.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-18-2006 03:33 AM
тАО05-18-2006 03:33 AM
Re: how to call profile function
put the code of your function(s) in a seperate file, e.g. /usr/local/bin/myfuncs .
This single file you can source in your .profile as well as in other shell scripts via
. /usr/local/bin/myfuncs
mfG Peter