Page 1 of 1

Single String Http Command Help

Posted: Wed Aug 29, 2018 4:09 pm
by Aaron407
I have a driveway alarm running a a dry contact to a 3B+ GPIO input that notifies me over email of someone driving down our driveway. I would also like to use this to trigger the recording of a specific camera on my system through Blue Iris, which can accept http commands through a browser to trigger camera recording if typed as follows:


I've confirmed that it works fine on local devices when executed through a web browser. I'm trying to figure out the best way to incorporate this into a pi script that's triggered based on the GPIO. Running a script at startup to monitor the GPIO is easy, but I'm not overly experienced with http commands. Can anyone suggest how to send this type of command in a single string and what libraries to utilize?

Any help would be greatly appreciated!

Re: Single String Http Command Help

Posted: Wed Aug 29, 2018 9:04 pm
by lmarmisa
I recommend the command wget:

Code: Select all

wget http://localIP:port/admin?camera=West&trigger&user=admin&pw=xxxxxxxxxx -O myfile

The command curl could be an alternative too.

There is a python module named wget too:

Re: Single String Http Command Help

Posted: Wed Aug 29, 2018 10:40 pm
by Aaron407
Thanks. I may give that a try. I have had some success with urllib, but there seems to be some issues when running it in shell versus running it from boot. I could get it running properly in a shell window when importing urllib.request, but the library couldn't be found when using a standard python shebang to call the python interpreter. It seems that urllib.request works with python3, though so I tried changing it to call python3, but still had the same error. It seems to work on boot if I would import the deprecated urllib rather than urllib.request and call with urllib.urlopen rather than urllib.request.urlopen, but then doesn't work in shell. That's a bit too buggy to me, so I may give the wget library option a try to simplify things.

Thanks again.

Re: Single String Http Command Help

Posted: Thu Aug 30, 2018 9:17 am
by scotty101
Always use python-requests rather than urllib.
requests eliminates all the confusion between urllib/urllib2/etc