[Klug-general] Bash quote woes!
Benjamin Donnachie
benjamin at py-soft.co.uk
Tue Jan 27 16:41:20 UTC 2009
I'd be very very VERY grateful if someone could please help with the
following bash fragment:
[...]
function connecteddrives()
{
connecteddrives=""
# /proc/partitions is in format "major minor blocks device" and first two
# lines are junk.
for drive in $( cat /proc/partitions | awk '{ if (NR > 2) print $4 }' )
do
local details=$( hdparm -I /dev/$drive 2>&1 )
local model=$( echo "$details" | grep "Model Number: " )
local serial=$( echo "$details" | grep "Serial Number: " )
if [ "x" == "x$model" ] ; then
model="Unable to get details."
serial="USB or SCSI?"
fi
connecteddrives="$connecteddrives $drive \"$model\" OFF \"$serial\""
done
}
connecteddrives
echo $connecteddrives
Xdialog --backtitle "Proof of concept Hard Drive erase program"
--title "HD Nuke" \
--item-help --separate-output --checklist "Please select the
drives you wish to nuke\n \
\nThis program will attempt to use the on-board security erase command. \
If not available, it will fall back to over-writing" 30 61 6 \
$connecteddrives
[...]
It should return a list of partitions in the following format for
display as a checklist using xdialog:
Drive "Model number" OFF "Serial number"
The echo statement confirms that the format is fine:
sda " Model Number: WDC WD2500AAJS-60VWA1 " OFF " Serial Number:
WD-WCARY0581557" sda1 " Model Number: WDC WD2500AAJS-60VWA1 " OFF "
Serial Number: WD-WCARY0581557" sda2 " Model Number: WDC
WD2500AAJS-60VWA1 " OFF " Serial Number: WD-WCARY0581557" sda5 " Model
Number: WDC WD2500AAJS-60VWA1 " OFF " Serial Number: WD-WCARY0581557"
But xdialog fails to display properly as per attached screen shot. If
I cut and paste the above in then it works fine.
Clearly quotes are being misinterpreted somewhere along the line.
I've tried all-sorts including including trying to use the output from
`echo $connecteddrives` but that still fails....
It's no doubt going to be something simple, but it's driving me nuts....
Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: broke.png
Type: image/png
Size: 10372 bytes
Desc: not available
Url : http://mailman.lug.org.uk/pipermail/kent/attachments/20090127/81021f3f/attachment-0001.png
More information about the Kent
mailing list