<?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: Shell script, different result in different O/S??? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017554#M64308</link>
    <description>Hi steven,&lt;BR /&gt;&lt;BR /&gt;I know that i posted in HPUX forms, because I thought u guys respond well and I trust u guys. I always had a good response from this site, thats the reason I posted here thinking that it  is not the part of O/S related. It is the part of the script.&lt;BR /&gt;&lt;BR /&gt;Any ways thanks for the time!</description>
    <pubDate>Mon, 11 Jun 2007 13:56:15 GMT</pubDate>
    <dc:creator>Qcheck</dc:creator>
    <dc:date>2007-06-11T13:56:15Z</dc:date>
    <item>
      <title>Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017552#M64306</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Can you please let me know what the following script is doing:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;function myFunction {&lt;BR /&gt;ls | while read i&lt;BR /&gt;  do&lt;BR /&gt;    if [ -d "$i" ]; then&lt;BR /&gt;      echo "Directory: $i";&lt;BR /&gt;&lt;BR /&gt;     elif [[ $i = wp_cancellation*.out ]];&lt;BR /&gt;     then&lt;BR /&gt;      echo "Initial Value EmailFlag $EMAILFLAG";&lt;BR /&gt;EMAILFLAG=2;&lt;BR /&gt;      echo "***Altered Value EmailFlag $EMAILFLAG *****wp_cancellation =&amp;gt; $i";&lt;BR /&gt;    fi;&lt;BR /&gt;&lt;BR /&gt;  done;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;  WP_IN=/webdata/dev/wp/inbound&lt;BR /&gt;  cd "$WP_IN";&lt;BR /&gt;EMAILFLAG=1;&lt;BR /&gt;&lt;BR /&gt;myFunction&lt;BR /&gt;{&lt;BR /&gt;  echo "Final Value EmailFlag $EMAILFLAG";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;**********************************************&lt;BR /&gt;&lt;BR /&gt;I get the following result, when I run the script on Linux server:&lt;BR /&gt;&lt;BR /&gt;Directory: kris&lt;BR /&gt;Initial Value EmailFlag 1&lt;BR /&gt;***Altered Value EmailFlag 2 *****wp_cancellation =&amp;gt; wp_cancellation20070611112859.out&lt;BR /&gt;Final Value EmailFlag 1&lt;BR /&gt;&lt;BR /&gt;***********************************************&lt;BR /&gt;&lt;BR /&gt;But the user complains when he runs the same script on a Tru64 node he gets the following result:&lt;BR /&gt;&lt;BR /&gt;Directory: kris&lt;BR /&gt;Initial Value EmailFlag 1&lt;BR /&gt;***Altered Value EmailFlag 2 *****wp_cancellation =&amp;gt; wp_cancellation20070611112859.out&lt;BR /&gt;Final Value EmailFlag 2&lt;BR /&gt;&lt;BR /&gt;I couldn't figure out why???&lt;BR /&gt;&lt;BR /&gt;Any help is greatly appreciated. I know it is nothing related to the O/S issue. But how can I prove to them??&lt;BR /&gt;&lt;BR /&gt;Since Tru64 is going to be end-of-life, we are migrating to Linux environment(node). My question why the final value is different in Linux and Tru64???&lt;BR /&gt;&lt;BR /&gt;Your time is greatly appreciated.&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Jun 2007 13:04:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017552#M64306</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-06-11T13:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017553#M64307</link>
      <description>&lt;!--!*#--&gt;You have a difference in behavior between&lt;BR /&gt;Linux and Tru64, so you ask about it in an&lt;BR /&gt;HP-UX forum?  How much sense does that make?&lt;BR /&gt;&lt;BR /&gt;What is "/usr/bin/ksh" on each system?&lt;BR /&gt;Perhaps there's a bug in one of the shells.&lt;BR /&gt;&lt;BR /&gt;As I read "man ksh" (on an HP-UX system), I'd&lt;BR /&gt;say that the Tru64 result is right, but my&lt;BR /&gt;opinion may not be worth much:&lt;BR /&gt;&lt;BR /&gt;      [...] Ordinarily,&lt;BR /&gt;      variables are shared between the&lt;BR /&gt;      calling program and the function.&lt;BR /&gt;      However, the typeset special command&lt;BR /&gt;      used within a function defines local&lt;BR /&gt;      variables whose scope includes the&lt;BR /&gt;      current function and all functions it&lt;BR /&gt;      calls.&lt;BR /&gt;      [...]&lt;BR /&gt;&lt;BR /&gt;To me, that says that EMAILFLAG is EMAILFLAG,&lt;BR /&gt;but I may be missing something.  (Similar for&lt;BR /&gt;the "{}" around the final "echo".)&lt;BR /&gt;&lt;BR /&gt;You could try a different shell, or change&lt;BR /&gt;the script to pass the result differently.&lt;BR /&gt;(Use a function return value, for example.)</description>
      <pubDate>Mon, 11 Jun 2007 13:46:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017553#M64307</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-06-11T13:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017554#M64308</link>
      <description>Hi steven,&lt;BR /&gt;&lt;BR /&gt;I know that i posted in HPUX forms, because I thought u guys respond well and I trust u guys. I always had a good response from this site, thats the reason I posted here thinking that it  is not the part of O/S related. It is the part of the script.&lt;BR /&gt;&lt;BR /&gt;Any ways thanks for the time!</description>
      <pubDate>Mon, 11 Jun 2007 13:56:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017554#M64308</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-06-11T13:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017555#M64309</link>
      <description>As usual, "Linux server" is not a complete&lt;BR /&gt;description of the system, and "ksh" is not a&lt;BR /&gt;a complete description of the shell being&lt;BR /&gt;used.  I tried a slightly modifed version of&lt;BR /&gt;your script on an HP TestDrive Linux system&lt;BR /&gt;and got the expected result:&lt;BR /&gt;&lt;BR /&gt;td178&amp;gt; /usr/bin/ksh vtx.sh&lt;BR /&gt;Directory: fred&lt;BR /&gt;Initial Value EmailFlag 1&lt;BR /&gt;***Altered Value EmailFlag 2 *****wp_cancellation =&amp;gt; wp_cancellation_fred.out&lt;BR /&gt;Final Value EmailFlag 2&lt;BR /&gt;&lt;BR /&gt;td178&amp;gt; uname -a&lt;BR /&gt;Linux td178.testdrive.hp.com 2.6.18-8.1.4.el5 #1 SMP Fri May 4 22:16:19 EDT 2007&lt;BR /&gt; ia64 ia64 ia64 GNU/Linux&lt;BR /&gt;&lt;BR /&gt;td178&amp;gt; /usr/bin/ksh --version&lt;BR /&gt;  version         sh (AT&amp;amp;T Labs Research) 1993-12-28 r&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt; it is not the part of O/S related. [...]&lt;BR /&gt;&lt;BR /&gt;No, but "ksh" probably came with the OS,&lt;BR /&gt;although with Linux, there's always some&lt;BR /&gt;doubt where anything came from.</description>
      <pubDate>Mon, 11 Jun 2007 17:22:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017555#M64309</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-06-11T17:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017556#M64310</link>
      <description>&amp;gt;But the user complains when he runs the same script on a Tru64 node he gets the following result:&lt;BR /&gt;&lt;BR /&gt;Is he complaining that Linux is broken?&lt;BR /&gt;&lt;BR /&gt;Basically Linux is broken.  hp-ux's sh, ksh and ksh.93 all agree the answer should be 2.&lt;BR /&gt;&lt;BR /&gt;And as Steven says, the script isn't using typeset to redeclare it.&lt;BR /&gt;&lt;BR /&gt;So you should really redirect this to a Linux thread.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Steven: (Similar for the "{}" around the final "echo".)&lt;BR /&gt;&lt;BR /&gt;That just makes that execute in the same enironment.   It seems that is only useful if you want to redirect the output of a whole block?&lt;BR /&gt;I also noticed a whole bunch of wasted ";" on the end of lines.</description>
      <pubDate>Mon, 11 Jun 2007 23:21:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017556#M64310</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-06-11T23:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017557#M64311</link>
      <description>&amp;gt; &amp;gt;Steven: (Similar for the "{}" around the final "echo".)&lt;BR /&gt;&lt;BR /&gt;&amp;gt; That just makes that execute in the same enironment.&lt;BR /&gt;&lt;BR /&gt;Exactly, so setting the variable in there&lt;BR /&gt;should not cause any trouble.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I also noticed [...]&lt;BR /&gt;&lt;BR /&gt;It may be that writing the script more&lt;BR /&gt;cleanly would lead to better results on the&lt;BR /&gt;(mystery) Linux system, but, as I said, it&lt;BR /&gt;worked as expected on the first Linux system&lt;BR /&gt;I tried, so it'd be too much work for me to&lt;BR /&gt;try to find the problem.&lt;BR /&gt;&lt;BR /&gt;True or false:  "If you've seen one Linux&lt;BR /&gt;system, you've seen them all."&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Since Tru64 is going to be end-of-life,&lt;BR /&gt;&amp;gt; [...]&lt;BR /&gt;&lt;BR /&gt;Which is better, an end-of life system which&lt;BR /&gt;works, or ...?</description>
      <pubDate>Mon, 11 Jun 2007 23:44:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017557#M64311</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-06-11T23:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017558#M64312</link>
      <description>The version of ksh on my Linux box is also broken:&lt;BR /&gt;Linux XXXX 2.6.5-7.139-default #1 SMP Fri Jan 14 15:41:33 UTC 2005 ia64 ia64 ia64 GNU/Linux&lt;BR /&gt;PD KSH v5.2.14 99/07/13.2&lt;BR /&gt;&lt;BR /&gt;This is 6 years newer than Steven's.</description>
      <pubDate>Mon, 11 Jun 2007 23:56:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017558#M64312</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-06-11T23:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017559#M64313</link>
      <description>&amp;gt; This is 6 years newer than Steven's.&lt;BR /&gt;&lt;BR /&gt;Well, it's 6 years newer than mine (HP's,&lt;BR /&gt;actually) _says_ it is.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Tad: Wake up, Tommy.&lt;BR /&gt;Tom Reagan: I am awake.&lt;BR /&gt;Tad: Your eyes are shut.&lt;BR /&gt;Tom Reagan: Who you gonna believe?</description>
      <pubDate>Tue, 12 Jun 2007 00:16:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017559#M64313</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-06-12T00:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017560#M64314</link>
      <description>The issue is that you're resetting the 'EMAILFLAG' variable within a piped (read: child) while loop.  All variables within the 'while' won't live outside of it.&lt;BR /&gt;&lt;BR /&gt;The way to get it to work is to not use a pipe, but a '&amp;lt;' on the other end of the while:&lt;BR /&gt;&lt;BR /&gt;ls &amp;gt; file&lt;BR /&gt;while read i&lt;BR /&gt;do&lt;BR /&gt;...&lt;BR /&gt;done &amp;lt; file&lt;BR /&gt;&lt;BR /&gt;(or if you're BASH happy:&lt;BR /&gt;&lt;BR /&gt;while read i&lt;BR /&gt;do&lt;BR /&gt;...&lt;BR /&gt;done &amp;lt; &amp;lt;(ls)&lt;BR /&gt;&lt;BR /&gt;but I don't think the Tru64 would allow it).&lt;BR /&gt;&lt;BR /&gt;Both 'pdksh' and 'bash' treat piped children in this manner, where as 'ksh' on most other unicies don't.&lt;BR /&gt;&lt;BR /&gt;Either way, the first form here should work on both.</description>
      <pubDate>Tue, 12 Jun 2007 01:42:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017560#M64314</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2007-06-12T01:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017561#M64315</link>
      <description>Morning All,&lt;BR /&gt;&lt;BR /&gt;Staurt! thank you so much, once I removed pipe and put &amp;lt; it worked. See! I knew I will get answer if I post here. &lt;BR /&gt;&lt;BR /&gt;Steven! See my problem has been solved even though I posted in hp forums. Thank you for your input though.&lt;BR /&gt;&lt;BR /&gt;Dennis! Thanks for your time too..&lt;BR /&gt;&lt;BR /&gt;Still I need to find why the same script doesn't work? when I did #/usr/bin/ksh --version, it says bad option. I also assume ksh is corrupted. Do you how can I download ksh and try???&lt;BR /&gt;&lt;BR /&gt;Thank you all for your time and answers, I really appreciate, this meant alot to me.&lt;BR /&gt;&lt;BR /&gt;Please try to throw some ideas if you guys find something, I am sure u will...;)&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Jun 2007 07:13:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017561#M64315</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-06-12T07:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017562#M64316</link>
      <description>&amp;gt;Steven! See my problem has been solved even though I posted in hp forums.&lt;BR /&gt;&lt;BR /&gt;You may be confused.  This thread was moved to Linux and then Stuart answered.  ;-)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;when I did #/usr/bin/ksh --version, it says bad option. I also assume ksh is corrupted.&lt;BR /&gt;&lt;BR /&gt;That didn't work for me either.  I got the version in vi editing mode when I typed control-V.</description>
      <pubDate>Tue, 12 Jun 2007 07:21:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017562#M64316</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-06-12T07:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017563#M64317</link>
      <description>Thank you Dennis! I didn't know this was moved to Linux. Thanks anyways...</description>
      <pubDate>Tue, 12 Jun 2007 07:34:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017563#M64317</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-06-12T07:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017564#M64318</link>
      <description>Yeap.. I'm a Penguin..&lt;BR /&gt;&lt;BR /&gt;Don't visit the HP-UX forums much any more..  Haven't had to touch one for about 3 years.. :)</description>
      <pubDate>Tue, 12 Jun 2007 07:51:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017564#M64318</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2007-06-12T07:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017565#M64319</link>
      <description>Staurt! How can I install ksh on my Linux node???</description>
      <pubDate>Tue, 12 Jun 2007 09:53:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017565#M64319</guid>
      <dc:creator>Qcheck</dc:creator>
      <dc:date>2007-06-12T09:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script, different result in different O/S???</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017566#M64320</link>
      <description>Not all Korn shells are created equal. Many Linux distributions ship pdksh as a Korn shell. pdksh implements KSH88, but I don't think it's even a fully-compatible implementation of that. Several years ago AT&amp;amp;T released the code for their KSH93 and some Linux systems now use that instead, others don't because of the AT&amp;amp;T license.&lt;BR /&gt;&lt;BR /&gt;I think most current UNIX platforms use KSH93, but there may still be a few KSH88 holdouts. If you want a Korn shell that will be just like the one on a modern commercial UNIX system you're almost certainly better off with the AT&amp;amp;T version instead of pdksh.</description>
      <pubDate>Tue, 12 Jun 2007 11:54:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-different-result-in-different-o-s/m-p/4017566#M64320</guid>
      <dc:creator>Heironimus</dc:creator>
      <dc:date>2007-06-12T11:54:56Z</dc:date>
    </item>
  </channel>
</rss>

