Rewrite small Perl script

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
vladimir
Posts: 5
Joined: Sat Sep 25, 2004 8:40 am

Rewrite small Perl script

Post by vladimir »

#!/usr/pkg/bin/perl

$mbmon = `sudo mbmon -c 1`;

$mbmon =~ /^Temp\.= (.*);(.*)$/m;
$1 =~ /^(.*),\s+(.*),\s+(.*)$/m;

print "case:$1 cpu:$2";


-------------------------------------------

The script vil put out two tempatures. I only want the CPU tempature. Would someone help me to rewrite the script.

I'm currently getting this error when running /cmd.php
ERROR: expected 1 data source readings (got 2)
vladimir
Posts: 5
Joined: Sat Sep 25, 2004 8:40 am

Post by vladimir »

I found out.

#!/usr/bin/perl

$mbmon = `mbmon -c 1`;

$mbmon =~ /^Temp\.= (.*);(.*)$/m;
$1 =~ /^(.*),\s+(.*),\s+(.*)$/m;

print "$2";
-----------------------------------------------

But then another question. The Perlscript then write out for example

39.5 degrees

How do I rewrite it to output the result without comma. For example

39



????
tulmad
Posts: 7
Joined: Thu Sep 23, 2004 3:55 pm

Re: Rewrite small Perl script

Post by tulmad »

#!/usr/pkg/bin/perl

$mbmon = `sudo mbmon -c 1`;

$mbmon =~ /^Temp\.= (.*);(.*)$/m;
$1 =~ /^(.*),\s+(.*),\s+(.*)$/m;

print int($2);
vladimir
Posts: 5
Joined: Sat Sep 25, 2004 8:40 am

Post by vladimir »

Thank you for the reply. I used this on FreeBSD to get the CPU temperature.
-----------------------------------------------------------------------

#!/bin/sh
temp2=`/usr/local/bin/mbmon -T 3 -c 1 -i`

/bin/expr $temp2

exit 0
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests