<?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: Creating Functions in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539287#M701686</link>
    <description>(I think DCL is a lot more readable :-)&lt;BR /&gt;&lt;BR /&gt;Gilbert,&lt;BR /&gt;  you may get more help in the HPUX scripting forum&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/categoryhome.do?categoryId=150" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/categoryhome.do?categoryId=150&lt;/A&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 06 May 2005 08:48:24 GMT</pubDate>
    <dc:creator>Ian Miller.</dc:creator>
    <dc:date>2005-05-06T08:48:24Z</dc:date>
    <item>
      <title>Creating Functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539285#M701684</link>
      <description>Hi, it was suggested I post this in this forum.&lt;BR /&gt;&lt;BR /&gt;When I create a function by pasting the code to create the function into a script and run the script, the script runs but when I try to execute the function, I get the message &lt;BR /&gt;ksh: get_time2: not found&lt;BR /&gt;However, if I just paste the code to the command line, it works.&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;oracle [/m02/oracle/scripts]&lt;BR /&gt;#get_time.ksh&lt;BR /&gt;&lt;BR /&gt;oracle [/m02/oracle/scripts]&lt;BR /&gt;#get_time2&lt;BR /&gt;ksh: get_time2: not found.&lt;BR /&gt;&lt;BR /&gt;oracle [/m02/oracle/scripts]&lt;BR /&gt;#more get_time.ksh&lt;BR /&gt;function get_time2 {&lt;BR /&gt;TIME=$(date '+%m/%d/%y-%H:%M:%S')&lt;BR /&gt;printf "$TIME\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;oracle [/m02/oracle/scripts]&lt;BR /&gt;#function get_time2 {&lt;BR /&gt;&amp;gt; TIME=$(date '+%m/%d/%y-%H:%M:%S')&lt;BR /&gt;&amp;gt; printf "$TIME\n"&lt;BR /&gt;&amp;gt; }&lt;BR /&gt;&lt;BR /&gt;oracle [/m02/oracle/scripts]&lt;BR /&gt;#get_time2&lt;BR /&gt;05/05/05-18:20:10&lt;BR /&gt;&lt;BR /&gt;Question: how can I create the functions using code that executes within a shell script?</description>
      <pubDate>Fri, 06 May 2005 08:06:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539285#M701684</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2005-05-06T08:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539286#M701685</link>
      <description>Well, OpenVMS does not have a Korn shell ;-)&lt;BR /&gt;&lt;BR /&gt;I think you have to do what is called 'source' the script:&lt;BR /&gt;# ./get_time.sh</description>
      <pubDate>Fri, 06 May 2005 08:31:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539286#M701685</guid>
      <dc:creator>Uwe Zessin</dc:creator>
      <dc:date>2005-05-06T08:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539287#M701686</link>
      <description>(I think DCL is a lot more readable :-)&lt;BR /&gt;&lt;BR /&gt;Gilbert,&lt;BR /&gt;  you may get more help in the HPUX scripting forum&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/categoryhome.do?categoryId=150" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/categoryhome.do?categoryId=150&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 06 May 2005 08:48:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539287#M701686</guid>
      <dc:creator>Ian Miller.</dc:creator>
      <dc:date>2005-05-06T08:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539288#M701687</link>
      <description>Hi, replies are appreciated, but am not on OpenVMS ... not sure how that got into the mix ?&lt;BR /&gt;will move it to the scripting forum !&lt;BR /&gt;Gil</description>
      <pubDate>Fri, 06 May 2005 09:33:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539288#M701687</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2005-05-06T09:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539289#M701688</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;You cannot call a function from the prompt, only a existing script.&lt;BR /&gt;&lt;BR /&gt;Try the following:&lt;BR /&gt;Content get_time.ksh&lt;BR /&gt;#####&lt;BR /&gt;function get_time2 {&lt;BR /&gt;TIME=$(date '+%m/%d/%y-%H:%M:%S')&lt;BR /&gt;printf "$TIME\n"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;get_time2&lt;BR /&gt;&lt;BR /&gt;#####&lt;BR /&gt;&lt;BR /&gt;Darrel</description>
      <pubDate>Sat, 07 May 2005 03:53:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539289#M701688</guid>
      <dc:creator>Darrel Louis</dc:creator>
      <dc:date>2005-05-07T03:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539290#M701689</link>
      <description>function names and definitions are not inherited by scripts or across seperate invocations of ksh.  you should put function definitons in a file whose name is the name of the function, in a directory defined in the FPATH variable.&lt;BR /&gt;&lt;BR /&gt;for a simple example:&lt;BR /&gt;&lt;BR /&gt;in get_time.ksh&lt;BR /&gt;&lt;BR /&gt;FPATH=/m02/oracle/functions&lt;BR /&gt;get_time2&lt;BR /&gt;&lt;BR /&gt;create a file named get_time2 in the /m02/oracle/functions directory with your funtion definition within</description>
      <pubDate>Sat, 07 May 2005 19:49:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539290#M701689</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2005-05-07T19:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539291#M701690</link>
      <description>A script looks like this:&lt;BR /&gt;&lt;BR /&gt;check_network() {&lt;BR /&gt;&lt;BR /&gt;  $SCMD network status &amp;gt; /dev/null&lt;BR /&gt;  rcode=$?&lt;BR /&gt;  # echo "Network status return code: ${rcode}"&lt;BR /&gt;return $rcode&lt;BR /&gt;&lt;BR /&gt;} # End check_network()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It is sourced into another script that with code like this:&lt;BR /&gt;&lt;BR /&gt;. /usr/contrib/bin/functions&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any scrip; with this line can now call the function check_network()&lt;BR /&gt;&lt;BR /&gt;Thats from a bash script but I think it should work with the korn shell.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Sun, 08 May 2005 12:23:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539291#M701690</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2005-05-08T12:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539292#M701691</link>
      <description>Hi gilbert,&lt;BR /&gt;&lt;BR /&gt;In general, if you create a function in one shell, only that shell recognises the function.&lt;BR /&gt;When executing a script using ./script.sh a new shell is opened, script is executed, feedback is given and shell gets closed.&lt;BR /&gt;That's why you can't create a script with a function and after running the script, trying to execute the function.&lt;BR /&gt;If you run the script by . script.sh, the script is executed in the current shell, but that's not recommended. The FPATH variable is preferred.&lt;BR /&gt;&lt;BR /&gt;Cheerio,&lt;BR /&gt;&lt;BR /&gt;Renarios</description>
      <pubDate>Mon, 09 May 2005 06:02:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/creating-functions/m-p/3539292#M701691</guid>
      <dc:creator>renarios</dc:creator>
      <dc:date>2005-05-09T06:02:42Z</dc:date>
    </item>
  </channel>
</rss>

