Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Okay Macfags Little Perl help here!

Name: Anonymous 2008-05-21 8:30

I don't know if you Macfags use Geektool but I find it really pleasant to have terminal scripts running in the desktop background.

Now al ittle problem here.
Y'see I want to display the internet bandwidth by using a Perl script.
Problem is, I couldn't get the lastTxRate to display on RATE: /Mb/s

Here's the script

$en0_info = `ifconfig en0 | grep "inet" | grep -v 127.0.0.1`;
$en1_info = `ifconfig en1 | grep "inet" | grep -v 127.0.0.1`;
$airport_info = `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I`;

if($en0_info)
{
    $en0_info =~ /inet (.*) netmask/s;
    $output .= "ETHERNET IP   : $1\n";

}
else
{ $output .= "ETHERNET IP   : INACTIVE\n";}


if($en1_info)
{
    $en1_info =~ /inet (.*) netmask/s;
    $en1_info = $1;
    $airport_info =~ /lastTxRate: (\d )/s;
    $airport_rate = $2;
    $airport_info =~ /BSSID(.*?)SSID: (.*?)\n/s;
    $airport_SSID = $2;
    $output .= "AIRPORT  STATUS: CONNECTED\n";
    $output .= "         SSID : $airport_SSID\n";
    $output .= "         RATE : $airport_info Mb/s\n";
    $output .= "AIRPORT  IP   : $en1_info\n";
}
else
{ $output .= "AIRPORT  STATUS: INACTIVE\n";}

print "$output";

Name: Anonymous 2008-05-21 8:38

$airport_rate = $2; should be $airport_rate = $1;

Name: Anonymous 2008-05-21 8:52

Yeah, I did that but output ends up like this:

ETHERNET IP   : INACTIVE
AIRPORT  STATUS: CONNECTED
         SSID : default
         RATE : 192.168.2.101 Mb/s
AIRPORT  IP    : 192.168.2.101

Name: Anonymous 2008-05-21 9:36

paste output of `ifconfig en0 | grep "inet" | grep -v 127.0.0.1`, `ifconfig en1 | grep "inet" | grep -v 127.0.0.1`, `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I`

Name: Anonymous 2008-05-21 9:47

    commQuality: 42
     rawQuality: 26
 avgSignalLevel: -73
  avgNoiseLevel: -96
     linkStatus: ESS
       portType: Client
     lastTxRate: 24
        maxRate: 54
lastAssocStatus: 1
          BSSID: xx:xx:xx:xx:xx:xx
           SSID: default
       Security: none

the ifconfigs have no output

Name: Anonymous 2008-05-21 10:26

$airport_info =~ /lastTxRate:(\d )/s;
lastTxRate: 24
Well, that's not going to match, obviously.

Name: Anonymous 2008-05-21 12:14

1. Your regexp is wrong, should be /lastTxRate: (\d+)/
2. You should add checks to your code to prevent situations like the one you're in now: $airport_info =~ /lastTxRate: (\d+)/s or die "I am a massive faggot and don't know how to write regexes";
3. You don't need to use $1 here: (my $airport_rate)=$airport_info=~/lastTxRate: (\d+)/s

Name: Anonymous 2008-05-21 12:30

Awesome! Thanks man!

Name: Anonymous 2008-05-21 14:04

I find it really pleasant to have terminal scripts running in the desktop background.

Name: Anonymous 2008-05-21 16:47

>>9
Why did you quote that?! Now some faggot will come here and...

Name: Anonymous 2008-05-21 17:10

>>10
``Welcome to /prog/ -- we find it really pleasant to have terminal scripts running in the desktop background.''?

Name: >>10 2008-05-21 20:13

>>11
Not what I meant, but you won some terminal scripts to run in the desktop background. Here, take.

Name: Anonymous 2008-05-21 21:39

I know it doesn't involve perl or geektool but there's an excellent menubar addon thing called menumeters that can display per-connection bandwidth like this and does a bunch of other shit too.

http://www.ragingmenace.com/software/menumeters/

Name: Anonymous 2009-03-06 11:47


The BEST EDITOR EVER!

Name: ​​​​​​​​​​ 2010-09-07 21:34

Name: Anonymous 2011-02-03 2:46

Name: Anonymous 2011-02-04 16:07

Name: Sgt.Kabukiman쾈奾 2012-05-23 5:59

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List