I basically have a backend program written in perl. This program pushes some configuration onto a network device. It gives a lot of output and I want users to be able to see the program as it runs. Up to now this has been easy as I have been running from the terminal.
Now I am trying to write a django app. I basically want a user to press submit, the browser to bring them to a new page and on this new page I want the user to see the text output of that program as it runs.
I have managed to get the program running in the backgroound using: http://docs.python.org/library/subprocess.html
Say the below is a simple request. In the response webpage I want to see the output of the program running live or at least refresh to see the latest output every few seconds (might be a workaroudn for now)
def config(request):
builder_Config_list = Config.objects.all().order_by('-generated_date')[:100]
if 'hostname' in request.POST and request.POST['hostname']:
hostname = request.POST['hostname']
command = "path/to/builder.pl --router " + hostname
result = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
return render_to_response('config/config.html', {'result':result, } )