sudo lshw > filename - can't open in gedit
sktsee
sktsee at tulsaconnect.com
Wed Jan 16 17:34:24 UTC 2008
On Tue, 2008-01-15 at 16:52 -0800, NoOp wrote:
> I've noticed a problem lately when saving a lshw to a file:
>
> sudo lshw > filename
>
> When I attempt to open the file in the text editor (gedit 2.20.3) I get
> the following error message:
>
> Could not open the file </path&filename>
> gedit has not been able to detect the character coding.
> Please check that you are not trying to open a binary file.
> Select a character codoing from the menu and try again.
> Character Coding: Current Locale (UTF-8)
> [also gives me a choice for Western (ISO-8859-15)
>
> Now, if I open the file in OpenOffice Writer & resave as a standard text
> file I can open in gedit. When I do open in OOo, it comes up with a font
> type as "Cumberland". If I open in Abiword it comes up as "Times New
> Roman".
>
> I've checked Terminal|Set Character Encoding| and it is set for "Current
> Locale (UTF-8). And, I can open the saved file in Nano, so I'm not sure
> what the problem could be. Anyone else have a similar problem?
>
>
Gedit did the same thing on my machine. It's caused by some null
characters being included in the output from lshw, specifically within
the serial number string from my cdrom device. I believe that the null
characters fool gedit into thinking the file is a binary data file, and
gedit won't edit binary files IIRC. After removing the null characters
and re-saving the file with vim, gedit has no problem with the file.
lshw probably should strip out the null characters or replace them with
spaces before sending to standard out.
--
sktsee
More information about the ubuntu-users
mailing list