As a newbie to the exciting world of raspberry pi i have to following situation.
On the one hand i have an raspi with an button connected to the gpio and a bash script that registers button presses. This works wonderful.
Also i have a php-script which reads the actual ip- and mac-adress of the raspi - this script works also wonderful when called on the build-in-browser on the raspi.
On the other hand i have an windows 2012r2 based iis with an asp.net webpage which awaits the call of this page by the raspi-php-script with the params ip and mac.
When i call the php-script on the raspi-browser everything works perfect. But the call by the bash-script is not even going out? What do i have to change?
Here is the bash-script:
#!/bin/sh
gpio mode 2 in
while true
do
result="$( gpio read 2 )"
if [ "$result" = "0" ]; then
php /var/www/html/buttom.php
echo "go"
fi
sleep 0.5
done
Here is the php-script "buttom.php"
#!/usr/bin/php
<?php
$ip = trim(shell_exec("/sbin/ifconfig wlan0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'"));
$mac = trim(shell_exec("/sbin/ifconfig wlan0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:digit:]]{1,2}'"));
$search = array (0 => ':',);
$replace = array (0 => '',);
$subject = $mac;
$mac = (str_replace( $search, $replace, $subject) );
$vars = array('ip' => $ip, 'mac' => $mac);
$querystring = http_build_query($vars);
$url = "http://www.mydomain.de/inbound/buttom.aspx?".$querystring;
header("Location: $url");
?>
I would be so grateful for any advice :D