- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Issues amending a running shell script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 07:55 AM
02-26-2003 07:55 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 07:58 AM
02-26-2003 07:58 AM
Re: Issues amending a running shell script
An error message would be helpful.
Inexperienced vi users can inadvertantly put in characters that will break the script.
I recommend starting over with the original, making the changes if not too extensive and seeing if the problem recurs.
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.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 08:09 AM
02-26-2003 08:09 AM
Re: Issues amending a running shell script
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.
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.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 08:10 AM
02-26-2003 08:10 AM
SolutionDepending on the size, the shell does appear to occasionally reread the script file and if you have amended it then anything could happen.
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.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 08:18 AM
02-26-2003 08:18 AM
Re: Issues amending a running shell script
I've encounonted this too on rare occassions in a large script with plenty of functions, althought that may not related.
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).
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 08:40 AM
02-26-2003 08:40 AM
Re: Issues amending a running shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 08:51 AM
02-26-2003 08:51 AM
Re: Issues amending a running shell script
It was a long running script with a number of functions.
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.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 08:58 AM
02-26-2003 08:58 AM
Re: Issues amending a running shell script
#!/bin/sh
for i in 1 2 3 4 5 6 7 8 9 0
do
echo $i
sleep 3
done
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.
Run the script again. This time remove the 10 chars and save before it finishes. It will complete successfully.
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.
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 08:58 AM
02-26-2003 08:58 AM
Re: Issues amending a running shell script
You can prove this by openining two sessions. In one session, create a script with the following:
sleep 10
echo "Hello world"
Save it, and chmod it so you can run it.
On the other session, vi the script and change it (don't write it out yet though).
sleep 10
echo "Hello world again"
In the first session, start your script.
In the second session, save your changes.
You'll see your script in the first session fail:
/=> ./test
Hello world
./test[3]: syntax error at line 4 : `"' unmatched
Run your script again straight away, and it will work:
/test
Hello world again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 10:32 AM
02-26-2003 10:32 AM
Re: Issues amending a running shell script
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2003 10:39 AM
02-26-2003 10:39 AM
Re: Issues amending a running shell script
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.
Thus changes to script file may or may not be executed depending on what needs to be re-read from the script file.
HTH
-- Rod Hills