#!/usr/bin/perl
#  $Id: pm_toggle 22944 2011-06-10 13:16:24Z abaranetsky $
# -----------------------------------------------------------------------------
#  Name:       pm_toggle
#  Purpose:    turn registered process executio non or off
#  Parameters: 1 - process name defined at registration
#              2 - new process state - one of the following: on|off|ON|OFF|1|0
#
#  env:        following variables are required:  APL
# -----------------------------------------------------------------------------
#  Author: A Baranetsky
#  Edited by: A Baranetsky
#  QA by:  Christopher C Gettings
#  Copyright: videoNEXT LLC
# -----------------------------------------------------------------------------

use strict;
use warnings;
use SKM::PM;



sub printUsage {
	print "Usage:  pm_toggle process-name on|off|ON|OFF|1|0\n";
}


my $exitCode = 0;

if ($#ARGV < 0) {
	printUsage();
	$exitCode = 2;
} elsif ($#ARGV >= 0 && ($ARGV[0] eq '-h' || $ARGV[0] eq '--help')) {
	printUsage();
} elsif ($#ARGV < 1) {
	printUsage();
	$exitCode = 2;
} else {
	$exitCode = 1 if (toggleProcess($ARGV[1], $ARGV[0]) == 0);
}

exit $exitCode;
