<?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: ksh scripting concepts in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-scripting-concepts/m-p/4764681#M657320</link>
    <description>&lt;!--!*#--&gt;Hi Michael:&lt;BR /&gt;&lt;BR /&gt;1.  Variables are global in scope and can be used (updated and/or referenced in all functions (subroutines).  &lt;BR /&gt;&lt;BR /&gt;2.  Variables declared in the scope of a subroutine are actually added to the global namespace unless they are declared with 'typeset' in which case they are local to the subroutine and "disappear" (or are restored to their global state) once the subroutine is exited.&lt;BR /&gt;&lt;BR /&gt;For example, consider:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;X=michael&lt;BR /&gt;function who&lt;BR /&gt;{   &lt;BR /&gt;    echo "my last 'Y' was '${Y}'"&lt;BR /&gt;    typeset Y=somebody&lt;BR /&gt;            Z=whoever #...no typeset...&lt;BR /&gt;    echo "my global value is '${X}'"&lt;BR /&gt;    typeset X=someone_else&lt;BR /&gt;    echo "my local  value is '${X}'"&lt;BR /&gt;    echo "I am '${Y}'"&lt;BR /&gt;}&lt;BR /&gt;who&lt;BR /&gt;echo "'${X}' and '${Y}' and '${Z}'"&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;3.  I'm not sure what you mean by "sub procedures".&lt;BR /&gt;&lt;BR /&gt;4.  Environmental variables are variables that are inherited from a process's parent.  A child process can use and modify an environmental variable but any modification is not propagated back to its parent.  See #1, above.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 14 Mar 2011 00:25:55 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2011-03-14T00:25:55Z</dc:date>
    <item>
      <title>ksh scripting concepts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-scripting-concepts/m-p/4764680#M657319</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;i'm not sure if i'm in the right forum.. i'm on my 6th day in studying Unix Shell (specifically ksh scripting) and i need help about some concept that i cannot specifically find over the net (maybe i should say this - my background is Visual Basic scripting):&lt;BR /&gt;&lt;BR /&gt;- what's the concept of variable settings for: &lt;BR /&gt;  1. main script  '(do variables here become "global" and can be used within called functions?)&lt;BR /&gt;  2. functions  '(do variables created here retain its values once script has exited from the function?)&lt;BR /&gt;  3. (any sub procedures in ksh?)&lt;BR /&gt;  4. can we create "Environment" variables in ksh? (i mean variables that are created anywhere but can be used throughout the whole script)&lt;BR /&gt;&lt;BR /&gt;please itemize your replies.. it means a lot.. thanks!&lt;BR /&gt;&lt;BR /&gt;~michael</description>
      <pubDate>Sun, 13 Mar 2011 23:54:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-scripting-concepts/m-p/4764680#M657319</guid>
      <dc:creator>stormmykL</dc:creator>
      <dc:date>2011-03-13T23:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: ksh scripting concepts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-scripting-concepts/m-p/4764681#M657320</link>
      <description>&lt;!--!*#--&gt;Hi Michael:&lt;BR /&gt;&lt;BR /&gt;1.  Variables are global in scope and can be used (updated and/or referenced in all functions (subroutines).  &lt;BR /&gt;&lt;BR /&gt;2.  Variables declared in the scope of a subroutine are actually added to the global namespace unless they are declared with 'typeset' in which case they are local to the subroutine and "disappear" (or are restored to their global state) once the subroutine is exited.&lt;BR /&gt;&lt;BR /&gt;For example, consider:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;X=michael&lt;BR /&gt;function who&lt;BR /&gt;{   &lt;BR /&gt;    echo "my last 'Y' was '${Y}'"&lt;BR /&gt;    typeset Y=somebody&lt;BR /&gt;            Z=whoever #...no typeset...&lt;BR /&gt;    echo "my global value is '${X}'"&lt;BR /&gt;    typeset X=someone_else&lt;BR /&gt;    echo "my local  value is '${X}'"&lt;BR /&gt;    echo "I am '${Y}'"&lt;BR /&gt;}&lt;BR /&gt;who&lt;BR /&gt;echo "'${X}' and '${Y}' and '${Z}'"&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;3.  I'm not sure what you mean by "sub procedures".&lt;BR /&gt;&lt;BR /&gt;4.  Environmental variables are variables that are inherited from a process's parent.  A child process can use and modify an environmental variable but any modification is not propagated back to its parent.  See #1, above.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Mar 2011 00:25:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-scripting-concepts/m-p/4764681#M657320</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-03-14T00:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: ksh scripting concepts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-scripting-concepts/m-p/4764682#M657321</link>
      <description>&amp;gt;3. any sub procedures in ksh?&lt;BR /&gt;&lt;BR /&gt;You can have aliases.  And functions in other files through FPATH.</description>
      <pubDate>Mon, 14 Mar 2011 01:56:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-scripting-concepts/m-p/4764682#M657321</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-03-14T01:56:00Z</dc:date>
    </item>
  </channel>
</rss>

