Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Programming & Scripting > WRT54GL Router LED Control...Script Help Needed...

Forgot Password?
 Linux Programming & Scripting   C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 02-02-2008   #1 (permalink)
Just Joined!
 
Join Date: Feb 2008
Posts: 1
WRT54GL Router LED Control...Script Help Needed...

I cannot get this script to run...Could you Please help...I am just a very beginner so I will need direct assistance to be of any value...I Thank You for any attempt you make...There may be just a loop error or even a syntax error...I don't know...Thanks again...


Project Description: Bash Linux Script...WRT54GL Router...LED Control...

3 print servers will be Totally Ignored.

A Blinking Amber Cisco LED will indicate that 1 or more of 4 cameras are accessing the router while nothing else is.

A Steady Amber Cisco LED will indicate that a client other than or in addition to a camera is accessing the router.

A Steady White Cisco LED will indicate there is activity by these other clients.

A Dark Cisco LED will indicate that no client is accessing the router.

------------------------------------------------------------------------
Code:
### Define Variables ###
clientpresent="amber on"
clientactive="white on"
ledsoff="amber off white off"
I=`nvram get wl0_ifname`

#Start the loop
while sleep 1 ; do

## Initialize ##
seecameras=""
clientsminusprinters=""
blinkamber=""
clientleds=""

### Define Functions ###
#look for camera macs
seecameras ()
{
if [ [ wl assoclist | grep A1:B1:C1:D1:E1:F1 || wl assoclist | grep A2:B2:C2:D2:E2:F2 || wl assoclist | grep A3:B3:C3:D3:E3:F3 ] ]; then
     return 0 # true
   else
     return 1 # false
fi
}

#look for clients other than printer macs
clientsminusprinters ()
{
ignoredmacs=$(wl assoclist | grep -v A1:B1:C1:D1:E1:F1 | grep -v A2:B2:C2:D2:E2:F2 | grep -v A3:B3:C3:D3:E3:F3)
if [ -n "ignoredmacs" ] ; then
    return 0  # true
  else
    return 1  # false
  fi
}

#blink amber led function
blinkamber () 
{ 
led amber off
sleep 1
led amber on 
}

#client present leds
clientleds ()
{
XFER=`ifconfig $I|grep bytes`
if [ "$XFER" != "$PXFER" ]; then
	LED=$clientactive
	PXFER=$XFER
	else
	LED=$clientpresent
fi
if [ "$LED" != "$PLED" ]; then
        led $LED
        PLED=$LED
fi
}

### MAIN ###

if [ [ seecameras && clientsminusprinters == 1 ] ]; then
blinkamber

elif [ [ clientsminusprinters && seecameras ] ]; then
clientleds

else
#default command
led $ledsoff
fi
done
joelinkup is offline  


Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 08:34 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2