LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-14-2012, 01:30 PM   #1
WeBMartians
LQ Newbie
 
Registered: Jun 2007
Posts: 6

Rep: Reputation: 0
Can Somebody Explain: lm-sensors and sensors-detect...


Odd behavior when invoking/launching sensors-detect from within a BASH script...
Code:
/sbin/modprobe w83627ehf
/usr/sbin/sensors-detect < /usr/bin/yes YES
The sensors-detect script (Perl) seems to treat the first response as NO; all of the others are YES.

The host environment is 2.6.18-164.el5PAE (CentOS).

From the console, the behavior is nominal:
  • Console
    Code:
    /usr/sbin/sensors-detect
    and, then, answer, manually ... you get the expected results
  • Automation
    Code:
    /usr/sbin/sensors-detect < /usr/bin/yes YES
    produces the expected results

...but code the automated code in a BASH script and sensors-detect seems to ignore the first prompt result (treating it as a NO)!

I made a modified copy of sensors-detect (sensors-detectYES) that treats the first prompt result as 1 (true, YES, ... whatever) and all seems OK ... it's ugly but it works.

Does anybody have an explanation for what's happening?

Last edited by WeBMartians; 03-14-2012 at 01:34 PM.
 
Old 03-14-2012, 08:47 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,421

Rep: Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597
Quote:
Originally Posted by WeBMartians View Post
Odd behavior when invoking/launching sensors-detect from within a BASH script...
Code:
/sbin/modprobe w83627ehf
/usr/sbin/sensors-detect < /usr/bin/yes YES
The sensors-detect script (Perl) seems to treat the first response as NO; all of the others are YES.
With that syntax you are not executing the /usr/bin/yes program. You are taking the content of the /usr/bin/yes binary file and sending that to the stdin of sensors-detect. I wouldn't care to guess about how sensors-detect will parse that gibberish. Try either of these:
Code:
/usr/bin/yes YES | /usr/sbin/sensors-detect

/usr/sbin/sensors-detect <(/usr/bin/yes YES)    # This is wrong, sorry

Last edited by rknichols; 03-15-2012 at 11:26 PM. Reason: Flag erroneous answer
 
Old 03-15-2012, 09:53 AM   #3
WeBMartians
LQ Newbie
 
Registered: Jun 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Batting 500

The former approach ("pipe")
Code:
#!/bin/bash
/sbin/modprobe w83627ehf
/usr/bin/yes YES | /usr/sbin/sensors-detect
seems to work.

The latter
Code:
#!/bin/bash
/sbin/modprobe w83627ehf
/usr/sbin/sensors-detect <(/usr/bin/yes YES)
just hangs ... even when executed, from the console, outside of a script.

Since the pipe technique works (and I understand it ... I swear I did try it that way, earlier ... sigh), that's what I'm going with ("Ship it!").

As to why the latter does not work, I haven't a clue: a learning experience for the future.

Thank you for your advice and help! I very much appreciate it.
 
Old 03-15-2012, 11:19 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,421

Rep: Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597
Quote:
Originally Posted by WeBMartians View Post
The latter
Code:
#!/bin/bash
/sbin/modprobe w83627ehf
/usr/sbin/sensors-detect <(/usr/bin/yes YES)
just hangs ... even when executed, from the console, outside of a script.

Since the pipe technique works (and I understand it ... I swear I did try it that way, earlier ... sigh), that's what I'm going with ("Ship it!").

As to why the latter does not work, I haven't a clue: a learning experience for the future.
That would be because I was posting in haste and made a mistake. It's just plain wrong. (It would work for programs like cat, that read either from stdin or from a filename passed as an argument. sensors-detect does not do the latter.)
 
  


Reply

Tags
bash, explain, perl, sensors


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
sensors-detect not detecting sensors on my dell laptop (XPS L401X) themande Linux - Newbie 1 10-20-2011 04:07 PM
lm-sensors does not find all sensors / solved ! g-string 3 Linux - Software 3 06-25-2010 04:24 PM
GNOME Sensors Applet says NO SENSORS FOUND! badgerbox76 Linux - Newbie 2 12-24-2005 11:58 AM
detect sensors Santas Linux - Software 3 06-17-2004 09:20 AM
sensors won't detect synaptical Linux - Software 5 07-11-2003 01:59 AM


All times are GMT -5. The time now is 01:35 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration