euglug.org

[Eug-lug] Reading data to multiple variables

작성자

카테고리:



Garl GrigsbyThu Jul 29 16:02:11 PDT 2004

Bob Miller wrote:

> Files in /proc aren't real files, so they probably don't support being
>
>read line-by-line.  I didn't have any USB storage devices handy to
>test against, so I didn't notice.  Sorry.
>
>  
>
No problem, I was more commenting for the archives and anybody else 
following along.

>If you're planning to deploy this where security matters, I suggest
>you use a secure temp file name:
>
>	tmp=`mktemp`
>	cat "$unit" > "$tmp"
>	while ...
>	done < "$tmp"
>	rm "$tmp"		# cleanliness is next to
>
>  
>
Never thought of that. I will keep that in mind.

>Or you might be able to read by lines by buffering the input with cat.
>
>	cat "$unit" | while read name value
>		      do ...
>		      done
>
>  
>
I tried that and got even weirder results.

Now for the best part, after I got the entire script working as I 
desired I ran into another, more serious problem. I had been writing 
this script using 1 external USB drive and my usb thumb drive. That 
worked fine. Until the second USB hard drive arrived and I found a 
rather nasty problem: I found out that the GUID, which is supposed to be 
a unique ID, isn't. It appears that with this particular external HDD 
chassis the GUID is based on the controller, not on the controller + the 
drive like it is supposed to be. So both drives appear to be identical 
when plugged in. Now I need to figure out how to ID each driver.

But on the up side this entire thing has been a good learning experience.

Again, thanks for all the suggestions. Now I need to band my head 
against the wall.

Garl