Motion - Batch Control Of Motion

Batch control of motion

Introduction

What does it do? I've written a small bash script for those who want to control motion by batch or cron and for instance stop detetction automatically at a certain timer or so.

Detailed Description

Attached Files

Installation

What do you need to install before?

This script requires perl LWP packages to be properly installed.

Users Guide

motionctrl.sh: control motion by batch and cron

Synopsis: motionctrl.sh [-h] [-v] [-r <credentials file>] [-H <hostname>] [-p <portnum>] [-U <username] [-P <passwd>] [{-c <cam> -a <action>} ...]

-h gives this output.

Instead of passing username and password on the command line, it is possible to put them in to a file and pass
this file with parameter -r to motionctrl.sh. The file must consist of one line containing the username and the password,
delimited by space and termitated by cr/nl.

motionctrl.sh takes following parameters:
optional parameters:
        hostname:       host to connect to (localhost)
        portnum:        port to connect to (8080)
        username:       username to log in (admin)
        passwd:     password to log in (admin)
All optional parameters must be set before any camera action parameters on the command line.
mandatory parameters:
        cam:     cam to control, refers to the thread # in motion (cam # 0 menas all cameras!)
        action:  action to be passed to the motion thread controling this cam.
                 Actually, this is the path part of the motion html control interface, but some handy
                 abbreviations exist, see below.

Actions:
        long name            short name
        detection/start      dstart
        detection/pause      dpause
        detection/status     dstatus
        detection/connection dcon
        (all "action" part of the html control interface, it's obviously the path part of the URL)

Actions can be repeated on the command line. For instance:
        motionctrl.sh -c 0 -a dpause -c 1 -a dstart
turns off detection on cam 0 and turns on detection on cam 1.
Multiple action parts always refer to the last left camera. For instance
        motionctrl.sh -c 0 -a dpause -a detection/status
would first turn off detection on cam 0 and then retrieve the current detection status of the same camera.


Comments and Bug Reports


I do something similar with cron jobs that do:

pkill -STOP motion (evening) pkill -CONT motion (morning)

-- JonZeeff - 12 Nov 2008
Topic revision: r2 - 12 Nov 2008, JonZeeff
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.