; docformat = 'rst'
;+
; Example of communicating with an external program via pipes using SPAWN.
;
; :Params:
; input : in, optional, type=numeric or string
; the input to be doubled by the Python program
;-
pro mg_run_python, input
compile_opt strictarr
_input = n_elements(input) eq 0L ? 1.0 : input
spawn, 'python python_doubler.py', unit=lun
print, 'Sending ' + strtrim(_input, 2) + ' to python_doubler.py...'
printf, lun, _input
line = ''
readf, lun, line
print, 'Response: ' + line
free_lun, lun
end