echo.py 442 B

1234567891011121314151617181920
  1. #!/usr/bin/env python3
  2. """echo.py - Simply echo the environment and the stdin."""
  3. import os
  4. import sys
  5. import json
  6. def main():
  7. # NOTE: even if not used, ALWAYS consume sys.stdin to close the pipe.
  8. print('STDIN JSON: %s' % repr(json.loads(sys.stdin.read())))
  9. print('')
  10. print('ENV: %s' % repr(os.environ))
  11. if __name__ == '__main__':
  12. try:
  13. main()
  14. except Exception as e:
  15. print('echo.py error: %s' % e)