Re: cgi-script shell script wrapping question
Hi, I would go to the javascript wrapper solution : I would wrap cgi-script to send javascript code to browser and then redirect original script output to the html file In a javascript I would loop (and sleep) until load of html file will succeed. On 12/27/2010 08:26 PM, Dov Grobgeld wrote: Thanks for the help! Based on it I tried running the command with python as follows: import subprocess pipe = subprocess.Popen(do_slow_command 21, bufsize=1, stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) for p in pipe.stdout.readlines(): print p,br\n According to the subprocess documentation, this is supposed to set up line by line mode. But I still get things buffered up. But perhaps that is because I did not tell do_slow_command to flush after print command, and it senses that it is not being run under a terminal? I'll try that. Dov On Mon, Dec 27, 2010 at 20:08, ik ido...@gmail.com mailto:ido...@gmail.com wrote: 2010/12/27 shimi linux...@shimi.net mailto:linux...@shimi.net 2010/12/27 Dov Grobgeld dov.grobg...@gmail.com mailto:dov.grobg...@gmail.com I'm trying to write a cgi wrapper for a long running command. The command takes about 10minutes to execute and when running it from the command line it continously outputs text to stdout. A simplistic cgi-bin wrapper that tries to execute the script and then writes that it is done fails with the following message: Timeout waiting for output from CGI script ... What I wonder if there is any easy way to have continously update the web page with stdout of the script. One way, I guess would be to run the script in a separate thread and just do HTML reload on a static page which I would regenaret with the stdout generated so far. Is there any other simple solution? You could increase the timeout to be running time of the script ... Do not forget that you also have timeout of the web browser that you can not control (you can not control the users themselves). -- Shimi Ido ___ Linux-il mailing list Linux-il@cs.huji.ac.il mailto:Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il LINESIP - Opening the source for communication http://www.linesip.com http://www.linesip.com/ http://www.linesip.co.il http://www.linesip.co.il/ ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
cgi-script shell script wrapping question
I'm trying to write a cgi wrapper for a long running command. The command takes about 10minutes to execute and when running it from the command line it continously outputs text to stdout. A simplistic cgi-bin wrapper that tries to execute the script and then writes that it is done fails with the following message: Timeout waiting for output from CGI script ... What I wonder if there is any easy way to have continously update the web page with stdout of the script. One way, I guess would be to run the script in a separate thread and just do HTML reload on a static page which I would regenaret with the stdout generated so far. Is there any other simple solution? Regards, Dov ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: cgi-script shell script wrapping question
If you can send once in a while data to the output of the cgi, but not to finish the execution so it's pipe to the HTTP server will not terminate and the request will not end, then it should work, because there is a response, it's just keep on going, however if you do not send a thing, then the timeout will take place, because the timeout is on receiving content. Ido LINESIP - Opening the source for communication http://www.linesip.com http://www.linesip.co.il 2010/12/27 Dov Grobgeld dov.grobg...@gmail.com I'm trying to write a cgi wrapper for a long running command. The command takes about 10minutes to execute and when running it from the command line it continously outputs text to stdout. A simplistic cgi-bin wrapper that tries to execute the script and then writes that it is done fails with the following message: Timeout waiting for output from CGI script ... What I wonder if there is any easy way to have continously update the web page with stdout of the script. One way, I guess would be to run the script in a separate thread and just do HTML reload on a static page which I would regenaret with the stdout generated so far. Is there any other simple solution? Regards, Dov ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: cgi-script shell script wrapping question
2010/12/27 Dov Grobgeld dov.grobg...@gmail.com I'm trying to write a cgi wrapper for a long running command. The command takes about 10minutes to execute and when running it from the command line it continously outputs text to stdout. A simplistic cgi-bin wrapper that tries to execute the script and then writes that it is done fails with the following message: Timeout waiting for output from CGI script ... What I wonder if there is any easy way to have continously update the web page with stdout of the script. One way, I guess would be to run the script in a separate thread and just do HTML reload on a static page which I would regenaret with the stdout generated so far. Is there any other simple solution? You could increase the timeout to be running time of the script ... -- Shimi ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: cgi-script shell script wrapping question
2010/12/27 shimi linux...@shimi.net 2010/12/27 Dov Grobgeld dov.grobg...@gmail.com I'm trying to write a cgi wrapper for a long running command. The command takes about 10minutes to execute and when running it from the command line it continously outputs text to stdout. A simplistic cgi-bin wrapper that tries to execute the script and then writes that it is done fails with the following message: Timeout waiting for output from CGI script ... What I wonder if there is any easy way to have continously update the web page with stdout of the script. One way, I guess would be to run the script in a separate thread and just do HTML reload on a static page which I would regenaret with the stdout generated so far. Is there any other simple solution? You could increase the timeout to be running time of the script ... Do not forget that you also have timeout of the web browser that you can not control (you can not control the users themselves). -- Shimi Ido ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il LINESIP - Opening the source for communication http://www.linesip.com http://www.linesip.co.il ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: cgi-script shell script wrapping question
Thanks for the help! Based on it I tried running the command with python as follows: import subprocess pipe = subprocess.Popen(do_slow_command 21, bufsize=1, stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) for p in pipe.stdout.readlines(): print p,br\n According to the subprocess documentation, this is supposed to set up line by line mode. But I still get things buffered up. But perhaps that is because I did not tell do_slow_command to flush after print command, and it senses that it is not being run under a terminal? I'll try that. Dov On Mon, Dec 27, 2010 at 20:08, ik ido...@gmail.com wrote: 2010/12/27 shimi linux...@shimi.net 2010/12/27 Dov Grobgeld dov.grobg...@gmail.com I'm trying to write a cgi wrapper for a long running command. The command takes about 10minutes to execute and when running it from the command line it continously outputs text to stdout. A simplistic cgi-bin wrapper that tries to execute the script and then writes that it is done fails with the following message: Timeout waiting for output from CGI script ... What I wonder if there is any easy way to have continously update the web page with stdout of the script. One way, I guess would be to run the script in a separate thread and just do HTML reload on a static page which I would regenaret with the stdout generated so far. Is there any other simple solution? You could increase the timeout to be running time of the script ... Do not forget that you also have timeout of the web browser that you can not control (you can not control the users themselves). -- Shimi Ido ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il LINESIP - Opening the source for communication http://www.linesip.com http://www.linesip.co.il ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il