Greg Erskine wrote: 
> hi nimaazx,
> 
> Did you miss this post?
> 
> 
> > 
Code:
--------------------
  >   > #!/bin/sh
  > 
  > . /home/tc/www/cgi-bin/pcp-functions
  > 
  > echo $(pcp_lmsip)
  > 
--------------------
> > 
> 
> 
> regards
> Greg

Hey Greg, I had seen your post before, but I did not test it. I'm
inspired by "telnet" method. I use cli lms. maybe there is a simple way
for doing this. right now I don't have pcp and raspberry pi until
tomorrow. 
but I really like share my code with you.



Code:
--------------------
    sudo echo "17" > /sys/class/gpio/export
  sudo chown -R tc /sys/class/gpio/gpio17/
  sudo echo "out" > /sys/class/gpio/gpio17/direction
  mac=$(sudo cat /sys/class/net/wlan0/address)
  command=$mac' connected ?'
  host='192.168.1.17 9090'
  #///////////////////////////
  program(){
  result=$(
  (
  echo "$command"
  sleep 1
  echo "exit"
  ) | timeout -t 5 telnet $host )
  
  if [ "$result" != "Terminated" ]
  then
        data=$( (echo "$result") | cut -d ' ' -f3)
        if [ $data -eq 1 ]
        then
                return 1
        else
                return 0
        fi
  else
        return 0
  fi
  } #end of program
  #////////////////////////////////
  
  while true;
  do
        program
        dd=$?
        if [ $dd -eq 1 ]
        then
                echo "Connected"
                sudo echo "1" > /sys/class/gpio/gpio17/value            
        else
                echo "Not Connected"
                sudo echo "0" > /sys/class/gpio/gpio17/value
                
        fi
  sleep 2s
  done
  
--------------------


yeah, "$(pcp_lmsip)" this is exactly what I want .instead of writing
this code I could just check "$(pcp_lmsip)" this variable.:p if it is
filled turn on led.
I don't know if possible 20 30 pcp telnet to one lms server at one time
and lms windows app can handle their requests every 5 sec to check their
connection, it works or not. but just checking "$(pcp_lmsip)" , is not
dependable to network and telnet.


------------------------------------------------------------------------
nimaazx's Profile: http://forums.slimdevices.com/member.php?userid=68798
View this thread: http://forums.slimdevices.com/showthread.php?t=110118

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to