I am fiddling with a little script that will issue a shutdown command if the temperature on the CPU goes above a certain level. I started writing the script in Bash, and then thought I would like to use
Perl to extract the detailed bits, but I am not sure if this is really practical. Basically I want to parse the input a little better, but I am a bit of a novice at both Bash and
Perl. I know how to extract what I want with
Perl, but not so much with Bash. I know how to get the raw data with Bash, but I don't know how best to get that data to
Perl, and then back as a variable to Bash so it can decide whether to leave the machine running, or issue a shutdown command. I wrote the first bit of the Bash script, which was relatively simple, but now I am at a standstill as I don't know how to bring
Perl into the picture. Would my best bet be to write the 'raw data' to a file, and then call a
separate Perl script, have it alter the file data as necessary, then read in the newly parsed data (in Bash) and act on that? Here is what I have gotten so far:
Code:
#!/bin/bash
cur_tmp= sensors | grep 'CPU Temp:' \
| awk '{ print $3 }' \