Created
June 8, 2014 15:49
-
-
Save dekarrin/32f4aff9362f9c715935 to your computer and use it in GitHub Desktop.
Get and display computer temperature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sensor_data=$(sensors | tail -n +3 | sed -e 's/^.*: *+//' -e 's/\.\([0-9]\).*/.\1/' | xargs temp_stats | tail -n +2) | |
sensor_min=$(echo $sensor_data | cut -d ' ' -f 1) | |
sensor_max=$(echo $sensor_data | cut -d ' ' -f 2) | |
sensor_avg=$(echo $sensor_data | cut -d ' ' -f 3) | |
echo "$sensor_avg/$sensor_max" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while : | |
do | |
clear | |
sensors | |
sleep 5 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
int main(int argc, char ** argv) | |
{ | |
double * inputs = malloc((argc - 1) * sizeof(double)); | |
int i; | |
for (i = 1; i < argc; i++) | |
{ | |
char * end; | |
inputs[i-1] = strtod(argv[i], &end); | |
if (inputs[i-1] == 0 && (errno != 0 || end == argv[i])) | |
{ | |
fprintf(stderr, "Error: %s is not a valid number\n", argv[i]); | |
return 1; | |
} | |
} | |
if (argc >= 2) | |
{ | |
double mx = inputs[0]; | |
double mn = inputs[0]; | |
double sum = 0.0; | |
for (i = 0; i < argc-1; i++) | |
{ | |
if (mx < inputs[i]) | |
{ | |
mx = inputs[i]; | |
} | |
if (mn > inputs[i]) | |
{ | |
mn = inputs[i]; | |
} | |
sum += inputs[i]; | |
} | |
double avg = sum / (argc - 1); | |
printf("Min Max Mean\n"); | |
printf("%.1f %.1f %.1f\n", mn, mx, avg); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment