[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
tricky shell script question
tricky shell script question
Tue, 12 Feb 2008 17:17:14 +0000
Anyone know the answer to this?
Suppose the following scenario:
Edit new file 'p.sh' in vim.
Add these lines :
Now save the file in vim with ':w' and chmod +x it. Then open another terminal
and run the script. While that's sleeping, quickly add the following line to
the end of the script:
Now watch the terminal where the script was still running. I would
expect no output to be given, as I assumed the script is read into memory
at startup and not during execution and this is what happens on most
systems. On one server however, the 'bla' is echoed.
On another system, which has as far as I can tell the same OS configuration,
same version of bash (RHEL ES release 3; bash-2.05b-29.0.3),
same options displayed in 'shopt', same output if doing 'lsof | grep p.sh',
the script is runs as I initially expected, not outputting the 'bla' and I
haven't seen the above mentioned behaviour before in 7 years of working
with shell scripts.
What is the toggle or switch that makes it output this 'bla' on that particular
server or in other words, why is the script being kept open and apparently
read line by line? (10 nerd points for those with the right answer ;)
Please cc me at this email address as I'm not subscribed to the list.
thanks and kind regards,
ICT Systems Administration, West Midlands Fire Service
Streetsbrook Road, Solihull, West Midlands, B91 1QY
tel: 0121 380 6572 | fax: 0121 711 1699
mob: 077 6988 1400 (wmfs) | mob: 079 3187 5526 (backup)
pag: 076 5975 0398
West Midlands Fire Service
Unless expressly stated otherwise, the information contained in this e-mail is
confidential and is intended only for the named recipients. You must not copy,
distribute, or take any action or reliance upon it. Any unauthorised disclosure
of the information contained in this e-mail is strictly prohibited. If you have
received it in error please notify us immediately on 0121 380 6666 or return it
to mailto:address@hidden and then destroy it.
The information contained in this e-mail may be subject to public disclosure
under the Freedom of Information Act 2000. Unless the information is legally
exempt from disclosure, the confidentiality of this e-mail and your reply
cannot be guaranteed.
Any opinions expressed in this e-mail (including attachments) are those of the
author and do not necessarily reflect the opinions of West Midlands Fire
Service. Nothing in this e-mail message amounts to a contractual or other legal
commitment on the part of West Midlands Fire Service unless confirmed by a
communication signed on behalf of the Chief Fire Officer.
West Midlands Fire Service information is available from http://www.wmfs.net
This footnote also confirms that this e-mail message has been swept for the
presence of computer viruses but does not guarantee that it is free from
viruses and you should check all e-mail and attachments with your own
- tricky shell script question,
Erik-Jan Taal <=