Wednesday, January 2, 2019

Best way to run a shell script, using input value from Django?


Hello, 

I'm going to attempt to generalize my question to make this easier to answer. 

Lets say I have a simple terminal based shell script (e.g. multiply_by_two) that takes a number argument, then multiplies that number by 2, and returns the result into a result.txt file. 

I would enter something like this:
multiply_by_two -n 6

The -n flag asks what number I would like to multiply by 2. The result of this would be a result.txt, containing the number 12 inside. 


What I would like to do is develop a simple Djano application that contains a text field allowing me to input the number 6, then click "Submit."

This job will start on the server by running my custom multiply_by_two application with my input parameter (6), but when the job is finished and the result.txt is available, the browser will automatically download the file. 

To make this a tad bit more complex, lets say that the job takes 2 minutes to run. What would be the best way to monitor the job? Maybe I accidentally close the window.

Not looking for anyone to solve this, I'm just new to Django and want to know if someone can give me any pointers on where to start. Are there any apps existing that will help me not need to write everything from scratch, especially if 'monitoring' is needed? Would Celery be ideal for this?

Thanks for any input!

Regards,
Chris

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7da4b068-ac58-4c26-a0bc-ed4925f8a4f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment