<?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 a function (in a separate directory) from script ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032844#M718917</link>
    <description>Hi (again) Sam:&lt;BR /&gt;&lt;BR /&gt;'FPATH' is the search path for function definitions (colon-delimited, as you would expect).  Have a look at the 'sh-posix' man pages.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;</description>
    <pubDate>Thu, 24 Jul 2003 18:20:49 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2003-07-24T18:20:49Z</dc:date>
    <item>
      <title>How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032838#M718911</link>
      <description>I have one file for each function in a seperate directory . How do I call  functions from a script without putting the full functions in each of my script itself ?&lt;BR /&gt;Ex:&lt;BR /&gt;#pwd&lt;BR /&gt;/home/sam&lt;BR /&gt;#cat call_fun.sh&lt;BR /&gt;=============&lt;BR /&gt;export PATH=$PATH:/home/functions&lt;BR /&gt;echo HELLO&lt;BR /&gt;test&lt;BR /&gt;test2&lt;BR /&gt;=================&lt;BR /&gt;But this script only echoes HELLO but does&lt;BR /&gt;call the command in the function. Want an output of commands in file test and test2&lt;BR /&gt;&lt;BR /&gt;# pwd&lt;BR /&gt;/home/functions&lt;BR /&gt;================&lt;BR /&gt;#ls&lt;BR /&gt;test test2&lt;BR /&gt;# cat test&lt;BR /&gt;###File name: test&lt;BR /&gt;----------------&lt;BR /&gt;test()&lt;BR /&gt;{&lt;BR /&gt;pwd&lt;BR /&gt;whoami&lt;BR /&gt;}&lt;BR /&gt;--------------------&lt;BR /&gt;# cat test2&lt;BR /&gt;###File name: test2&lt;BR /&gt;----------------&lt;BR /&gt;test2()&lt;BR /&gt;{&lt;BR /&gt;whodu&lt;BR /&gt;ls &amp;gt;out&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks a bunch</description>
      <pubDate>Thu, 24 Jul 2003 17:30:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032838#M718911</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2003-07-24T17:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032839#M718912</link>
      <description>You can do it by "sourcing" your function files in your script.&lt;BR /&gt;&lt;BR /&gt;For example,&lt;BR /&gt;&lt;BR /&gt;. /fullpath/function1.sh&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Hai</description>
      <pubDate>Thu, 24 Jul 2003 17:33:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032839#M718912</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-07-24T17:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032840#M718913</link>
      <description>Hi Sam:&lt;BR /&gt;&lt;BR /&gt;You're on the right track.  Set the environmental variable FPATH in your hosting shell.  Here's an example:&lt;BR /&gt;&lt;BR /&gt;/tmp/fct.sh  &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;FPATH=/tmp/fcts&lt;BR /&gt;testme&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;the 'testme' function looks like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;function testme&lt;BR /&gt;{&lt;BR /&gt;  date&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...and is named '/tmp/fcts/testme' with execute permissions.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 24 Jul 2003 17:48:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032840#M718913</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-24T17:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032841#M718914</link>
      <description>a function must be defined, or found in a directory named by the FPATH variable before it is referenced.&lt;BR /&gt;&lt;BR /&gt;Additionally, you can put function difinitions in your environment file (.kshrc, etc) if you want them to be defined whenever the shell is invoked interatively.&lt;BR /&gt;&lt;BR /&gt;if you want to improve your shell's performance, put functions that you use infrequently in a directory named by FPATH, instead of putting the definitions in your environment file and use set -o nolog to keep function definitons from being stored in the history file.&lt;BR /&gt;&lt;BR /&gt;a function that becomes defined the first time it is referenced is called an auto-loaded function.  Its primary advantage is better performance, since the shell does not have to read the function definiton if you never referenced the function.&lt;BR /&gt;&lt;BR /&gt;you can specifiy that a function auto-load with the "autoload" preset alias.  when the shell first encounters an auto-loaded function, it uses the FPATH varialbe to search for a filename whose name matches that of the function.  this file must contain the definition of this function.&lt;BR /&gt;&lt;BR /&gt;you can load a library of related functions with the first reference to any of its members, by putting them all in one file.  For each function defined, you can us "ln" to create a filename with the name of the function that refers to this file.</description>
      <pubDate>Thu, 24 Jul 2003 18:12:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032841#M718914</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-24T18:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032842#M718915</link>
      <description>JRF,&lt;BR /&gt;And you are on the right path to 10 pts  !!!.&lt;BR /&gt;Out of curiosity, what does FPATH does. I was trying&lt;BR /&gt;PATH=$PATH:/tmp/functs in the script&lt;BR /&gt;But it would not work.&lt;BR /&gt;huge Thanks.</description>
      <pubDate>Thu, 24 Jul 2003 18:14:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032842#M718915</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2003-07-24T18:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032843#M718916</link>
      <description>Curt,&lt;BR /&gt;Thanks for the explanation for a question that I asked JRF. FPATH was little confusing to me. Until you explained it. Much thanks to you.&lt;BR /&gt;Sam</description>
      <pubDate>Thu, 24 Jul 2003 18:18:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032843#M718916</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2003-07-24T18:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032844#M718917</link>
      <description>Hi (again) Sam:&lt;BR /&gt;&lt;BR /&gt;'FPATH' is the search path for function definitions (colon-delimited, as you would expect).  Have a look at the 'sh-posix' man pages.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jul 2003 18:20:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032844#M718917</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-24T18:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032845#M718918</link>
      <description>Another quick question.How come after the execution of testme and then echo "NEXT FUNCTION" the second function testme2 does not get executed. I have the testme2 function in /tmp/fcts (just like testme)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;tmp/fct.sh &lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;FPATH=/tmp/fcts &lt;BR /&gt;testme &lt;BR /&gt;echo "NEXT FUNTION"&lt;BR /&gt;testme2&lt;BR /&gt;exit 0 &lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jul 2003 18:34:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032845#M718918</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2003-07-24T18:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032846#M718919</link>
      <description>Its working. actually, I was using function name "test" (and not testme2)and test has special meaning and so it was given me probs.&lt;BR /&gt;Thanks all&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jul 2003 18:42:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032846#M718919</guid>
      <dc:creator>Sammy_2</dc:creator>
      <dc:date>2003-07-24T18:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to call a function (in a separate directory) from script ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032847#M718920</link>
      <description>is the filename that contains the testme2 function called testme2?</description>
      <pubDate>Thu, 24 Jul 2003 18:43:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-in-a-separate-directory-from-script/m-p/3032847#M718920</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-24T18:43:50Z</dc:date>
    </item>
  </channel>
</rss>

