LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-30-2012, 08:14 AM   #1
markseger
Member
 
Registered: Jul 2003
Posts: 244

Rep: Reputation: 26
errors reading /sys data


I'm trying to pro grammatically get the speeds of all my networks by looping though the 'speed' entries in /sys/devices. Works great for things like:

/sys/devices/pci0000:00/0000:00:1c.5/0000:01:00.0/net/eth0/speed

but for some devices like /sys/devices/virtual/net/lo/speed I'm getting "cat: /sys/devices/virtual/net/lo/speed: Invalid argument"

appending 2>&1 to the command doesn't help so I'm not sure where the error is coming from. Is there some way I can tell that I shouldn't try to access the data because it's not there? I've gotta believe there is some way to tell. I just did spot an operstate which says things like up, down or unknown that may be the answer. BUt I also found a 'tun' device with a state of unknown which DOES report a speed.

Ideally I'd rather not have to read a second file but I suppose it is what it is.

btw - I can't simply list of set of device names to ignore because I never know what's going to show up/

-mark
 
Old 07-01-2012, 01:42 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Maybe this is too simplistic, but how about checking the return code ?.

Those /sys/devices/virtual/net/lo/* pseudo files "exist" on my non-virtualized system; cat of speed gets rc=1, opstate gets rc=0. Just toss the message in the bit bucket ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help reading xsession-errors-can't log in seth1987 Linux - Newbie 1 06-03-2012 03:40 AM
SATA Error -> sys hard reboot on Suse 11.3. board+hdd changed, still errors. chh4l123 Linux - Hardware 7 02-01-2011 10:34 AM
[SOLVED] Serial port : Read data problem, not reading complete data anujmehta Linux - Networking 5 09-06-2010 06:10 AM
Sys Unbootable: Udev Errors after upgrading to Etch kushalkoolwal Debian 7 05-15-2007 10:13 PM
I/O errors when reading from SCSI CDROM. RamiRuhayel Linux - Hardware 2 02-02-2003 03:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration