Register
It is currently Wed Oct 01, 2014 8:22 pm

Bash reading a script during execution


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Feb 19, 2010 4:23 pm   

Joined: Fri Feb 19, 2010 4:16 pm
Posts: 3
I am making a concerted effort to switch from csh/tcsh to bash after I read a paper trashing csh. I am using it everywhere at home on Linux anyway and it is only at work I have tcsh. So, one problem I had with The Bourne shell was that it did not seem to read the script and execute it from memory, as I could go edit the file and cause irregular results. Well,... I just noticed the same thing happens with bash. With an edit mid-execution of the file one seems to influence the execution. Why is this and what can be done about it.

Someone will say - "stop doing that" and others will ask why I did it. Well, I have a long running script which is called in a series by another master script. I saw something else that I would like in output as the first run was in progress, so I added it. Only, bash did not wait until the script was called anew to go and read the file on the disk.


Top
 Profile  
 PostPosted: Fri Feb 19, 2010 8:49 pm   
User avatar

Joined: Sat Jun 13, 2009 8:53 pm
Posts: 73
Location: Texas!
The script is interpreted, not compiled, so it is read line by line. Thus, if you edit whatever is not yet in the buffer, it will affect the execution of the script.

It was not clear from your question, but do you actually want to be able to change your script during execution (by another script, for example)? As you said -- don't do that! If you just want to make manual changes to the script so that you don't forget about them while it's running, just copy the file, edit the copy, and move it back onto the original when it's done running.

Good luck to you on your shell switch-over!

- thobbs
(BTW -- this is not really the "VERY basics")


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP