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

General discussion • How can I syntax check php scripts in webserver?

$
0
0
HELP!
I have a number of php scripts on my webserver which my RPi devices call for certain reporting tasks.
For instance there is a php script I wrote many years ago which is called when the RPi starts in order to report the current IP address of the RPi via email to me. This way I can locate the device and connect to it with ssh or VNC.

The php scripts are called from a shellscript (bash) using curl like this:

Code:

curl -m 10 -d "rpiaddr=$IPAddr" -d "rpiname=$RPIname" -d "rpiaddrwifi=$IPAddrWiFi $WiFiLevel" -d "rpimacaddr=$IPMac" -d "rpimacaddrwifi=$IPMacWiFi"  -d "rpissid=${WiFiSSID}" -d "sendemail=1" "https://$URL/php/ipreport.php"
Now I am having trouble with a script that is basically a modified copy of the ipreport.php script but should report another state of the RPi.
This script seems not to execute when I run it using a similar curl call! Nothing happens...

And there are no errors or anything like that returned either, even though I have added this at the start of the script:

Code:

echo "<br>Start reporting<br>\n";
When I write bash shellscripts (which I do often) I can check syntax using shellcheck and this works well to find stuff that will not work.

So my question is this:
How can I check the syntax of the failed php script?
I have not found anything like shellcheck to do this for php files...
I have now spent several days trying to figure out what is wrong with the php script and I cannot even get it to print out a message when running....
(It started as a copy of the ipreport script, which I have modified for the different output into the email but nothing else.)
If I abuse the ipreport script by setting the variables used there to the data I need to report, then I get the email sent.
But if I modify the script to create the correct email content and using other parameter names then it just silently refuses to work...

Statistics: Posted by Bosse_B — Thu Jan 16, 2025 7:36 am



Viewing all articles
Browse latest Browse all 4919

Trending Articles