<?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 defined in other script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309905#M683061</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Functions either use the syntax&lt;BR /&gt;function FUNCTION { COMMANDS; }&lt;BR /&gt;or&lt;BR /&gt;FUNCTION () { COMMANDS; }&lt;BR /&gt;&lt;BR /&gt;See the example:&lt;BR /&gt;&lt;BR /&gt;pathmunge () {&lt;BR /&gt;if ! echo $PATH | /bin/egrep â  q "(^|:)$1($|:)" ; then&lt;BR /&gt;if [ "$2" = "after" ] ; then&lt;BR /&gt;PATH=$PATH:$1&lt;BR /&gt;else&lt;BR /&gt;PATH=$1:$PATH&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;}&lt;BR /&gt;# Path manipulation&lt;BR /&gt;if [ `id â  u` = 0 ]; then&lt;BR /&gt;pathmunge /sbin&lt;BR /&gt;pathmunge /usr/sbin&lt;BR /&gt;pathmunge /usr/local/sbin&lt;BR /&gt;fi&lt;BR /&gt;pathmunge /usr/X11R6/bin after&lt;BR /&gt;unset pathmunge&lt;BR /&gt;&lt;BR /&gt;Suraj</description>
    <pubDate>Thu, 20 Nov 2008 09:34:12 GMT</pubDate>
    <dc:creator>Suraj K Sankari</dc:creator>
    <dc:date>2008-11-20T09:34:12Z</dc:date>
    <item>
      <title>how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309899#M683055</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I have script1.scr. I am calling datetime function which is defined in script2.scr and trying to get return value:&lt;BR /&gt;&lt;BR /&gt;cat script1.scr&lt;BR /&gt;./script2.scr&lt;BR /&gt;echo " Please call datetime function "&lt;BR /&gt;&lt;BR /&gt; dd=datetime("2008-11-13")&lt;BR /&gt; echo " date is $dd "&lt;BR /&gt;********************************************&lt;BR /&gt;&lt;BR /&gt;cat script2.scr&lt;BR /&gt;&lt;BR /&gt;givedate()&lt;BR /&gt;{&lt;BR /&gt;echo " welcome to date time fun "&lt;BR /&gt;val=$1&lt;BR /&gt;dd=`echo "$val" | cut -f3 -d'-'`&lt;BR /&gt;return $dd&lt;BR /&gt;}&lt;BR /&gt;*******************************************&lt;BR /&gt;&lt;BR /&gt;When i call function datetime from script1.scr it gives error that can not find function.&lt;BR /&gt;&lt;BR /&gt;Can some one assists what is correct way to call function get return value?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 20 Nov 2008 07:03:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309899#M683055</guid>
      <dc:creator>diwakar_4</dc:creator>
      <dc:date>2008-11-20T07:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309900#M683056</link>
      <description>Put ". ./script2.scr" in script2.scr&lt;BR /&gt;&lt;BR /&gt;This will source the functions defined in script2.scr.&lt;BR /&gt;&lt;BR /&gt;You should then be able to used the functions defined in script2.scr within script1.scr&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 20 Nov 2008 07:13:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309900#M683056</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2008-11-20T07:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309901#M683057</link>
      <description>Just to make it abit clearer.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;. ./script2.scr&lt;BR /&gt;&lt;BR /&gt;dd=$(givedate 2008-11-13)&lt;BR /&gt;echo "Date us $dd"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
      <pubDate>Thu, 20 Nov 2008 08:07:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309901#M683057</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2008-11-20T08:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309902#M683058</link>
      <description>&amp;gt;Can someone assist what is correct way to call function get return value?&lt;BR /&gt;&lt;BR /&gt;Either you source it as KU suggests.  You need to have ". ./script2.scr".&lt;BR /&gt;&lt;BR /&gt;Or you don't use call functions, you execute the whole other script.&lt;BR /&gt;&lt;BR /&gt;Or if you want to have functions in a file with the same name, you can use FPATH to point to a directory that contains the functions.</description>
      <pubDate>Thu, 20 Nov 2008 08:30:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309902#M683058</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-11-20T08:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309903#M683059</link>
      <description>Typo&lt;BR /&gt;&lt;BR /&gt;My post should have read&lt;BR /&gt;&lt;BR /&gt;Put ". ./script2.scr" in script1.scr&lt;BR /&gt;&lt;BR /&gt;Cheers</description>
      <pubDate>Thu, 20 Nov 2008 08:42:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309903#M683059</guid>
      <dc:creator>OFC_EDM</dc:creator>
      <dc:date>2008-11-20T08:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309904#M683060</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Many thanks, it is working after importing the path.&lt;BR /&gt;Now i am facing probelm in term of returning the code.&lt;BR /&gt;I am now passing lone date_time string as argument.&lt;BR /&gt;************************************&lt;BR /&gt;cat script1.scr&lt;BR /&gt;./script2.scr&lt;BR /&gt;echo " Please call datetime function "&lt;BR /&gt;&lt;BR /&gt;dd=datetime("2008-09-12:20300000")&lt;BR /&gt;echo " date is $dd "&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In script2.scr i want to return&lt;BR /&gt;&lt;BR /&gt;cat script2.scr&lt;BR /&gt;&lt;BR /&gt;givedate()&lt;BR /&gt;{&lt;BR /&gt;echo " welcome to date time fun "&lt;BR /&gt;val=$1&lt;BR /&gt;--"after formating the val"&lt;BR /&gt;dd=$date$Month$$Year_$hour$Min$Sec&lt;BR /&gt;return $dd&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here dd conatins value like "12012008183000". When i am returning this i am not getting full sting.&lt;BR /&gt;I think it is not able to handle such long value. Can we do someting?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 20 Nov 2008 09:19:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309904#M683060</guid>
      <dc:creator>diwakar_4</dc:creator>
      <dc:date>2008-11-20T09:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309905#M683061</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Functions either use the syntax&lt;BR /&gt;function FUNCTION { COMMANDS; }&lt;BR /&gt;or&lt;BR /&gt;FUNCTION () { COMMANDS; }&lt;BR /&gt;&lt;BR /&gt;See the example:&lt;BR /&gt;&lt;BR /&gt;pathmunge () {&lt;BR /&gt;if ! echo $PATH | /bin/egrep â  q "(^|:)$1($|:)" ; then&lt;BR /&gt;if [ "$2" = "after" ] ; then&lt;BR /&gt;PATH=$PATH:$1&lt;BR /&gt;else&lt;BR /&gt;PATH=$1:$PATH&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;}&lt;BR /&gt;# Path manipulation&lt;BR /&gt;if [ `id â  u` = 0 ]; then&lt;BR /&gt;pathmunge /sbin&lt;BR /&gt;pathmunge /usr/sbin&lt;BR /&gt;pathmunge /usr/local/sbin&lt;BR /&gt;fi&lt;BR /&gt;pathmunge /usr/X11R6/bin after&lt;BR /&gt;unset pathmunge&lt;BR /&gt;&lt;BR /&gt;Suraj</description>
      <pubDate>Thu, 20 Nov 2008 09:34:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309905#M683061</guid>
      <dc:creator>Suraj K Sankari</dc:creator>
      <dc:date>2008-11-20T09:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309906#M683062</link>
      <description>Diwakar,&lt;BR /&gt;&lt;BR /&gt;Since you're executing this within a variable (&amp;lt;3 that btw... DCL doesn't have that) you could just aswell use echo instead of return. In my experience this usually works better then using return.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
      <pubDate>Thu, 20 Nov 2008 09:38:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309906#M683062</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2008-11-20T09:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309907#M683063</link>
      <description>&amp;gt;I think it is not able to handle such long value. Can we do something?&lt;BR /&gt;&lt;BR /&gt;Functions can only return numbers 0..255.&lt;BR /&gt;Otherwise you would need to use echo:&lt;BR /&gt;&lt;BR /&gt;In function:&lt;BR /&gt;echo "$val" | cut -f3 -d'-'&lt;BR /&gt;&lt;BR /&gt;Caller:&lt;BR /&gt;dd=$(datetime "2008-11-13")&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Nov 2008 09:42:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309907#M683063</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-11-20T09:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to call a function defined in other script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309908#M683064</link>
      <description>Fredrik/Dennis,&lt;BR /&gt;&lt;BR /&gt;Thanks a ton,&lt;BR /&gt;&lt;BR /&gt;Echo worked fro me, let me do some testing on different scenarios, let you know if required any help.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Nov 2008 10:05:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-call-a-function-defined-in-other-script/m-p/4309908#M683064</guid>
      <dc:creator>diwakar_4</dc:creator>
      <dc:date>2008-11-20T10:05:26Z</dc:date>
    </item>
  </channel>
</rss>

