SOLUTION (edit 3):
I used these lines in my perl script:
system("curl -d \"username=USERNAME&password=PASSWORD&action=login&view=console\" -c cookies.txt http://localhost/zm/index.php");
system("curl -b cookies.txt http://localhost/zm/api/states/change/disarm.json");
Seems to work great. Hope this helps someone else!
EDIT 2: I see I need to format a cookies.txt file and probably use cURL for this. I was hoping for a quick command line solution, but I can use the API. If anyone has a suggestion on a quick one or two liner otherwise, let me know. I'd really like to be able to change run states from a perl script or shell script without using cURL.
EDIT: I'm able to use the /api/states/change/<name>.json to work from the browser URL bar, but from the command line it's complaining about 401 unauthorized. I'd be perfectly happy doing a wget from my control script, if I can get past this auth issue (I've tried user:pass@host and it's still not working).
I'm looking for some advice. I have recently upgraded to 1.29 using the installation from apt-get on Ubuntu 16.04. Everything going well, but I have one issue I'm encountering between zmpkg.pl and ZM as a "service" (if I'm understanding this correctly).
I have two run states in ZM: "armed" and "disarmed" which I use for away/home states. Armed has modect on all monitors, Disarmed has modect only on some and monitor/disabled on others. In previous ZM installations, I had used "zmpkg.pl <state>" to switch between modes. Now under 1.29, when I do that, ZM gets into a weird state where the service has failed, and zma is still running (for example, when I go from armed to disarmed, zma is still running on all monitors and is still capturing events even though the console says those monitors are set to "Monitor"). The only solution is to reboot, or I see this in systemctl logs:
Is there a new way to tell zoneminder to change state from the command line? I notice when I do this from the web console it works, so there must be a step I'm missing in my script to change states; I'd prefer not to have to sign into the web console every time I want to change states.
Code: Select all
Oct 06 07:37:05 home systemd: Failed to start ZoneMinder CCTV recording and surveillance system. Oct 06 07:37:05 home systemd: zoneminder.service: Unit entered failed state. Oct 06 07:37:05 home systemd: zoneminder.service: Failed with result 'exit-code'.