sendcmd.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/python3
  2. # Copyright (C) 2010 Internet Systems Consortium.
  3. #
  4. # Permission to use, copy, modify, and distribute this software for any
  5. # purpose with or without fee is hereby granted, provided that the above
  6. # copyright notice and this permission notice appear in all copies.
  7. #
  8. # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
  9. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  10. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  11. # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  13. # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  14. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  15. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. import isc, sys
  17. cc = isc.cc.Session()
  18. if len(sys.argv) < 3:
  19. sys.stderr.write('Usage: ' + sys.argv[0] + ' <channel> <command> [arg]\n')
  20. sys.exit(1)
  21. channel = sys.argv[1]
  22. command = sys.argv[2]
  23. if len(sys.argv) >= 4:
  24. argument = sys.argv[3]
  25. else:
  26. argument = ""
  27. cmd = { "command": [ command, argument ] }
  28. cc.group_subscribe(channel)
  29. print("Sending:")
  30. print(cmd)
  31. cc.group_sendmsg(cmd, channel)