Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3556

General programming discussion • Re: Push button to start shell script doen't work as expected

$
0
0
I got it to work after all!
However, in an endless loop and in the form of a bash script. That's certainly not nice, but I'm a little more familiar with Bash than with Python and it works until further notice...

Code:

#!/bin/bashecho "Monitoring button ..."previous_output=1while true; do  output=$(gpioget gpiochip4 8)  if [ "$output" -eq 0 ] && [ "$previous_output" -ne 0 ]; then    echo "Button pressed!"    bash /opt/backup.sh    wait    echo "Monitoring button ..."  fi  previous_output=$output  sleep 0.3done

Statistics: Posted by crabler — Mon Aug 05, 2024 3:25 pm



Viewing all articles
Browse latest Browse all 3556

Trending Articles