LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   how to access /dev/hdx (https://www.linuxquestions.org/questions/slackware-14/how-to-access-dev-hdx-244966/)

ngan_yine 10-20-2004 02:24 AM

how to access /dev/hdx
 
Hi
I am having problem with my hddtemp program to read the hd temperature on my /dev/hdx as normal user.I could read temperature in root mod but in normal user mod it said that I don't permission .I try changing like chmod 755 /dev/hdx .It change into read exute mod but I still didn't have enought permissions as normal user to use it at all.


thanks for reading
arkar kyaw win

rotvogel 10-20-2004 02:40 AM

What you could do is to make the hddtemp program suid. In that case the program will be run as if it was executed by root.

ngan_yine 10-20-2004 06:22 AM

I actually thought about this too but I don't like the idea of any program suid-ing itself ,it make me a little bit creepy .It there no other way around?

Thanks

Arkar Kyaw Win

malo_umoran 10-20-2004 06:40 AM

I think that hddtemp will not run without root ...

put it in "/etc/rc.d/rc.local" ...

hddtemp -d /dev/hd[ab]

and that's it ...

M.

ngan_yine 10-21-2004 11:09 AM

I had just tried it that way , put /usr/local/sbin/hddtemp -n /dev/hdb in /etc/rc.d/rc.local .I just the program load but I still couldn't access as normal user.

thanks
Arkar Kyaw win

Cedrik 10-21-2004 11:58 AM

after load the deamon as root :
hddtemp -d /dev/hda

to communicate with it, try as regular user :
telnet localhost 7634

ngan_yine 10-22-2004 12:32 AM

Hi thanks for the info ;
I had try it the way you told me telenet localhost 7634 and I could read it
but I don't know how to export it in to superkaramba or other monitor .But when
I open gtk system monitor ,it show the hddtemp /hdb and everything work out ok!
thanks
arkar kyaw win

Cedrik 10-22-2004 04:22 AM

You could do a little script, like this :

Code:

#!/usr/bin/perl

open HDDTEMP,"telnet localhost 7634 2>/dev/null|";

while(<HDDTEMP>){
        if(/\|/) {
                ($n,$dev,$model,$temp,$unit,$s) = split /\|/;

                # print device
                print "Device: $dev\n";

                # print drive model
                print "Model: $model\n";

                # print drive temperature
                print "Temperature: $temp$unit\n";
        }
}
close HDDTEMP;

save it, chmod x it and eventually remove/comment the things you don't want to display
Yes it do the same as hddtemp command line but it does not require root privilege to execute it, it requires that hddtemp is started as deamon though.

ngan_yine 10-22-2004 08:28 AM

Hi !

I really apperciate for the script.Now that I have the shell script it seem that I could insert my program into some karamba theme .Thanks man , It really mean a lot to me because I just re-compile my kernel to build i2c-chips into modules and I just found out after all that it didn't support the S.M.A.R.T hd heat sensors .Now it seem fine but the script only print out for one harddisk .I have two hd (hda and hdb) ,my linux box is on hdb.When I ran this command "telnet localhost 7634 2>/dev/null|" it sure did print out this line;
rying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
|/dev/hda|ST380011A|33|C||/dev/hdb|Maxtor 6E040L0|26|C|arkar@Ngan_yine:$
temp reading for both hd but when I run the script ,it show only one hd
arkar@Ngan_yine:$ ./hddtemp
Device: /dev/hda
Model: ST380011A
Temperature: 33C
I don't know anything about perl so I don't how to fix this loop or whatever the problem is ;
Can you please help me and fix it again please;


Thanks

Arkar Kyaw Win

Cedrik 10-22-2004 12:01 PM

Not a prob ;) Now the script should work with an unlimited drives number :

Code:

#!/usr/bin/perl

open HDDTEMP,"telnet localhost 7634 2>/dev/null|";

while(<HDDTEMP>){
    if(/\|/) {
        # this reg is just to help to split, remove first and last '|'
        $_ =~ s/^\|(.*)\|$/$1/;

        @drives = split /\|\|/;

        while(@drives) {
            $drive = shift @drives;
            ($dev,$model,$temp,$unit) = split /\|/, $drive;

            # print device
            print "Device: $dev\n";

            #print drive model
            print "Model: $model\n";

            #print $temperature
            print "Temperature: $temp$unit\n";

            # print new line for formating output
            print "\n";
        }
    }
}
close HDDTEMP;


ngan_yine 10-22-2004 04:23 PM

wow! it work !it fit like a glove and it work like there is no tommorrow.Gee thanks a million man ,I am really obsess with this heat reading because I had already fix more than 15 capaciter in my motherboard.I had to replace it twice ,last time I had to replace 10 and before that I had to replace 5 at least .And my cpu over heat so much that I had to take off my case cover off
and cool it off with small fan .That not all 3 weeks ago ,overheating process kill my ageing seagate .I know I need to change my cpu heat seeker and case too ,if I want to install extra fan in
it .And my system power box is right up in my cpu heatseeker so I really have a bad configure case.So I am just waiting for christmax sale to shop around cheap and good.In the mean time I
am really dead serious about heating.
Thanks for the srcipt .it really help,I am a pascal progmmer(student) and I never thought perl could do a lot of thing .I am dumping pascal as soon as course is over.thanks for script!


Thanks!

arkar kyaw win


All times are GMT -5. The time now is 06:46 PM.