- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: posix shell read loop premature EOF condition
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
Discussions
Discussions
Forums
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
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
тАО01-30-2006 04:41 AM
тАО01-30-2006 04:41 AM
posix shell read loop premature EOF condition
Say, for example, in the loop below, it terminated after line # 18, instead of the last line # 62.
>wc -l file1
62 file1
while read -r LINE
do
#does some work here
done
I know this is very general, but this week-end I ran a script that does this sort of thing, and it looked like it completed successfully, but only 18 out of 62 records were processed in the file.
Grasping for straws :-)
scott
- Tags:
- read
- while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2006 04:47 AM
тАО01-30-2006 04:47 AM
Re: posix shell read loop premature EOF condition
When a tried and true script that used to work stops, the first thing you want to check is the data.
Maybe do a quick hex dump and see if an unfortunate i/o problem put an EOF a little early.
The while code I'm familiar with and its always worked. Only and EOF character can bust that code according to my experience.
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
тАО01-30-2006 04:59 AM
тАО01-30-2006 04:59 AM
Re: posix shell read loop premature EOF condition
1) Your script and the wc commands were run at different times so that the file was only 18 lines long when read by your script. A short file was probably entirely loaded into buffer when the file was opened. This also assumes that both your script and the wc command actually read the same file -- not just files that share a common name.
2) There are non-ASCII characters embedded in your file. Use od or hd -v to make sure.
3) Your script is receiving a signal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2006 05:00 AM
тАО01-30-2006 05:00 AM
Re: posix shell read loop premature EOF condition
do a set -x at the top of your script, perhaps you can discover the mistake.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2006 05:12 AM
тАО01-30-2006 05:12 AM
Re: posix shell read loop premature EOF condition
Steven,
Checking the file for binary data was the 1st thing I looked at. Nothing untoward there.
A.Clay,
I think you've got it. The process that creates the file must have still had the file open for output, and when the script ran, there was only 18 records in the buffer. I'll need to beef up the coordination between the two separate processes.
Thanks again to all!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2006 05:15 AM
тАО01-30-2006 05:15 AM
Re: posix shell read loop premature EOF condition
Appologies -- I meant to give you 9 points, not 4. I can't seem to modify the assigned points now. Is there a way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2006 09:26 AM
тАО01-30-2006 09:26 AM