<?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: Issues amending a running shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913937#M107945</link>
    <description>I am with the developer on this one.  This has happened to me in the past when amending large, long running scripts.  If I set the script running, make further changes and then save them, then the script can fall over with a syntax error.  To avoid this I run a test copy of the script being changed.</description>
    <pubDate>Wed, 26 Feb 2003 16:40:25 GMT</pubDate>
    <dc:creator>Ian Lochray</dc:creator>
    <dc:date>2003-02-26T16:40:25Z</dc:date>
    <item>
      <title>Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913932#M107940</link>
      <description>I have had a query from a developer who had a running a shell script which he then amended. He claims that the fact that the script was amended whilst the original copy was running caused the script to fail. We feel that once a script is running on the system, editing the script should have no effect and its possible to even remove it. &lt;BR /&gt;&lt;BR /&gt;Does anyone have any views on this. The running script called an Informix isql session and it was this step (within an IF statement) that was runnning when the original script was amended.</description>
      <pubDate>Wed, 26 Feb 2003 15:55:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913932#M107940</guid>
      <dc:creator>Nick Wickens</dc:creator>
      <dc:date>2003-02-26T15:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913933#M107941</link>
      <description>It would be nice to know what the guy did to the script.&lt;BR /&gt;&lt;BR /&gt;An error message would be helpful.&lt;BR /&gt;&lt;BR /&gt;Inexperienced vi users can inadvertantly put in characters that will break the script.&lt;BR /&gt;&lt;BR /&gt;I recommend starting over with the original, making the changes if not too extensive and seeing if the problem recurs.&lt;BR /&gt;&lt;BR /&gt;I've made a few oracle help desk calls disappear by insisting my dba do this when a script "suddenly" stops working after a modification.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 26 Feb 2003 15:58:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913933#M107941</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-02-26T15:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913934#M107942</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I've wondered about this issue before, so I wrote a little test script and tried it out.  I ran the script and then modified the script while it was running.  The changes to the script don't get picked up in the already running process, so it looks like the shell script is read in at invocation and run from memory, which means that your developer's changes shouldn't have mattered to an existing process running that script.&lt;BR /&gt;&lt;BR /&gt;This seems to match up with the man pages for sh-posix and ksh, which say the script is read at invocation.  I could be wrong but this is how it looks to me.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Feb 2003 16:09:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913934#M107942</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-02-26T16:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913935#M107943</link>
      <description>I've seen this happen before. If you run fuser against a running script file, you'll notice that the shell process keeps it open. &lt;BR /&gt;&lt;BR /&gt;Depending on the size, the shell does appear to occasionally reread the script file and if you have amended it then anything could happen.&lt;BR /&gt;&lt;BR /&gt;The only solution that I know is to rename the in-use script with mv, copy it to the original name then vi that file. I always use a script that does this whenever I edit a script that may be running.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John</description>
      <pubDate>Wed, 26 Feb 2003 16:10:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913935#M107943</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2003-02-26T16:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913936#M107944</link>
      <description>Hi Nick:&lt;BR /&gt;&lt;BR /&gt;I've encounonted this too on rare occassions in a large script with plenty of functions, althought that may not related.&lt;BR /&gt;&lt;BR /&gt;Having been "bitten", I always edit a copy of any script that is running and then when I've debugged the new copy, I replace the original script with it (after terminating the original).&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 26 Feb 2003 16:18:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913936#M107944</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-02-26T16:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913937#M107945</link>
      <description>I am with the developer on this one.  This has happened to me in the past when amending large, long running scripts.  If I set the script running, make further changes and then save them, then the script can fall over with a syntax error.  To avoid this I run a test copy of the script being changed.</description>
      <pubDate>Wed, 26 Feb 2003 16:40:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913937#M107945</guid>
      <dc:creator>Ian Lochray</dc:creator>
      <dc:date>2003-02-26T16:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913938#M107946</link>
      <description>Thanks everyone.&lt;BR /&gt;&lt;BR /&gt;It was a long running script with a number of functions.&lt;BR /&gt;&lt;BR /&gt;I wonder if the script is re-read if it gets swapped out/in when its priority decreases because its been running for a long time.?</description>
      <pubDate>Wed, 26 Feb 2003 16:51:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913938#M107946</guid>
      <dc:creator>Nick Wickens</dc:creator>
      <dc:date>2003-02-26T16:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913939#M107947</link>
      <description>I've also been bitten by this, and haven't found the answer yet, though I can give you some ways to demonstrate it:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;for i in 1 2 3 4 5 6 7 8 9 0&lt;BR /&gt;do&lt;BR /&gt;echo $i&lt;BR /&gt;sleep 3&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Run the script and in a separate term append about 10 chars at the end of the echo line, then save it before it finishes.  The script will error when it completes.&lt;BR /&gt;&lt;BR /&gt;Run the script again.  This time remove the 10 chars and save before it finishes.  It will complete successfully.&lt;BR /&gt;&lt;BR /&gt;Edit the script and add 10 spaces to the end of the echo line.  Run the script, overwrite the 10 spaces with 10 chars and save before it finishes.  It will complete successfully.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;&lt;BR /&gt;Darren.</description>
      <pubDate>Wed, 26 Feb 2003 16:58:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913939#M107947</guid>
      <dc:creator>Darren Prior</dc:creator>
      <dc:date>2003-02-26T16:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913940#M107948</link>
      <description>The developer is correct. A shell script is interpreted, so each line is read and then executed. It is not read entirely into memory.&lt;BR /&gt;&lt;BR /&gt;You can prove this by openining two sessions. In one session, create a script with the following:&lt;BR /&gt;&lt;BR /&gt;sleep 10&lt;BR /&gt;echo "Hello world"&lt;BR /&gt;&lt;BR /&gt;Save it, and chmod it so you can run it.&lt;BR /&gt;&lt;BR /&gt;On the other session, vi the script and change it (don't write it out yet though).&lt;BR /&gt;&lt;BR /&gt;sleep 10&lt;BR /&gt;echo "Hello world again"&lt;BR /&gt;&lt;BR /&gt;In the first session, start your script.&lt;BR /&gt;In the second session, save your changes.&lt;BR /&gt;You'll see your script in the first session fail:&lt;BR /&gt;&lt;BR /&gt;/=&amp;gt; ./test&lt;BR /&gt;Hello world&lt;BR /&gt;./test[3]: syntax error at line 4 : `"' unmatched&lt;BR /&gt;&lt;BR /&gt;Run your script again straight away, and it will work:&lt;BR /&gt;&lt;BR /&gt;/test&lt;BR /&gt;Hello world again&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Feb 2003 16:58:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913940#M107948</guid>
      <dc:creator>Colin Topliss</dc:creator>
      <dc:date>2003-02-26T16:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913941#M107949</link>
      <description>The theory, I suppose, is that each command in a shell script runs in its own subshell until completing successfully.  So both you and your developer are both correct.  You cannot amend a running _command_, but you can amend/modify a shell script that is running commands, as long as it you're amending/modifying commands that are not currently executing.  A shell script is basically a series of commands run in sequence, with no command executing until the previous one terminates successfully or otherwise.  AFAIK, the shell script runs in a FIFO queue.  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Wed, 26 Feb 2003 18:32:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913941#M107949</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2003-02-26T18:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issues amending a running shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913942#M107950</link>
      <description>Just a thought-&lt;BR /&gt;&lt;BR /&gt;Could be if the script is small enough it will be run from memory only, but if it is large it may have to do re-reads on the script file.&lt;BR /&gt;&lt;BR /&gt;Thus changes to script file may or may not be executed depending on what needs to be re-read from the script file.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 26 Feb 2003 18:39:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issues-amending-a-running-shell-script/m-p/2913942#M107950</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-02-26T18:39:04Z</dc:date>
    </item>
  </channel>
</rss>

