<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to call profile function in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787476#M23372</link>
    <description>The functions defined in .bash_profile won't be visible to shell scripts by default.  You can use "export -f lcprod01" in your .bash_profile to make the lcprod01 function visible to shell scripts started from your login shell.&lt;BR /&gt;&lt;BR /&gt;  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.&lt;BR /&gt;&lt;BR /&gt;  One way to set a variable is to source the shell script.  You can to that with ./myscript.sh from your login shell.&lt;BR /&gt;That runs myscript.sh in your login shell instead of starting a new shell process to run it.&lt;BR /&gt;&lt;BR /&gt;  Another way is to source the output of your script as shell commands.  That approach is taken by the resize command.&lt;BR /&gt;$(resize)&lt;BR /&gt;says to evaluate the variable assignment commands that resize write to its stdout.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 15 May 2006 16:26:43 GMT</pubDate>
    <dc:creator>Mike Stroyan</dc:creator>
    <dc:date>2006-05-15T16:26:43Z</dc:date>
    <item>
      <title>how to call profile function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787473#M23369</link>
      <description>Red Hat Enterprise Linux 4&lt;BR /&gt;&lt;BR /&gt;I have a function into my profile:&lt;BR /&gt;&lt;BR /&gt;function lcprod01 {&lt;BR /&gt;export ORACLE_SID=lcprod01n1&lt;BR /&gt;PS1="[`hostname`*${ORACLE_SID} \${PWD}]$ "&lt;BR /&gt;dump&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;From the prompt I call the function just writing the name of the function. OK.&lt;BR /&gt;&lt;BR /&gt;How can I call the function from inside another shell script?&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;&lt;BR /&gt;$ MyScript.sh ProfileFunctionName&lt;BR /&gt;</description>
      <pubDate>Fri, 12 May 2006 12:51:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787473#M23369</guid>
      <dc:creator>Tonatiuh</dc:creator>
      <dc:date>2006-05-12T12:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to call profile function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787474#M23370</link>
      <description>Try adding this to MyScript.sh:&lt;BR /&gt;&lt;BR /&gt;source $HOME/.bash_profile&lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;. $HOME/.bash_profile</description>
      <pubDate>Fri, 12 May 2006 14:18:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787474#M23370</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2006-05-12T14:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to call profile function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787475#M23371</link>
      <description>Ivan,&lt;BR /&gt;&lt;BR /&gt;I am afraid that nothing of both options has worked.&lt;BR /&gt;&lt;BR /&gt;This is the code of my script.&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;#&lt;BR /&gt;# Description: De la base de datos especificada, mata todas las sesiones del usuario especificado&lt;BR /&gt;# Parametros de entrada: $1 = nombre/referencia de la instancia&lt;BR /&gt;#                        $2 = username del usuario a matar todas sus sesiones&lt;BR /&gt;#&lt;BR /&gt;# Set ORA_HOME equivalente a $ORACLE_HOME&lt;BR /&gt;# Set SCP_HOME equivalente a la ruta completa donde se encuentran los cripts&lt;BR /&gt;#&lt;BR /&gt;SCP_HOME=/home/oracle/scripts&lt;BR /&gt;ORA_HOME=/opt/oracle/rdbms/9.2.0&lt;BR /&gt;ORA_USER=$2&lt;BR /&gt;&lt;BR /&gt;. $HOME/.bash_profile&lt;BR /&gt;$1      #&amp;lt;- Here should call the function&lt;BR /&gt;&lt;BR /&gt;sqlplus /nolog $args &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;connect / as sysdba&lt;BR /&gt;spool $SCP_HOME/sessions_to_kill.sql&lt;BR /&gt;select instance_name from v\$instance;&lt;BR /&gt;select 'alter system kill session '''||sid||','||serial#||''';' from v\$session where username='$2';&lt;BR /&gt;spool off&lt;BR /&gt;exit&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And this is a sample code for the profile functions:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;function lcprod01 {&lt;BR /&gt;export ORACLE_SID=lcprod01n1&lt;BR /&gt;PS1="[`hostname`*${ORACLE_SID} \${PWD}]$ "&lt;BR /&gt;dump&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 May 2006 10:19:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787475#M23371</guid>
      <dc:creator>Tonatiuh</dc:creator>
      <dc:date>2006-05-15T10:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to call profile function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787476#M23372</link>
      <description>The functions defined in .bash_profile won't be visible to shell scripts by default.  You can use "export -f lcprod01" in your .bash_profile to make the lcprod01 function visible to shell scripts started from your login shell.&lt;BR /&gt;&lt;BR /&gt;  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.&lt;BR /&gt;&lt;BR /&gt;  One way to set a variable is to source the shell script.  You can to that with ./myscript.sh from your login shell.&lt;BR /&gt;That runs myscript.sh in your login shell instead of starting a new shell process to run it.&lt;BR /&gt;&lt;BR /&gt;  Another way is to source the output of your script as shell commands.  That approach is taken by the resize command.&lt;BR /&gt;$(resize)&lt;BR /&gt;says to evaluate the variable assignment commands that resize write to its stdout.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 May 2006 16:26:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787476#M23372</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2006-05-15T16:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to call profile function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787477#M23373</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;put the code of your function(s) in a seperate file, e.g. /usr/local/bin/myfuncs .&lt;BR /&gt;This single file you can source in your .profile as well as in other shell scripts via&lt;BR /&gt;. /usr/local/bin/myfuncs&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Thu, 18 May 2006 10:33:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-call-profile-function/m-p/3787477#M23373</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-05-18T10:33:21Z</dc:date>
    </item>
  </channel>
</rss>

