Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Perl-Sensitive Sunglasses
 
PerlMonks  

how to keep tracking the system command in cgi

by chennaiite (Sexton)
on Feb 10, 2006 at 11:59 UTC ( #529332=perlquestion: print w/ replies, xml ) Need Help??
chennaiite has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,
In my cgi script,
After creating a directiory,I have to run a seperate perl script,this script does some manipulation and installation.Also moves some files to that directory.
when a user tries to abort the execution, pressed stop or refresh button,i need to check the status of running perl script....
I need to delete the created folder if aborted or stopped for other user to access...

Note:I dont have rights to restrict the user and disable of IE buttons etc...

Please throw some lights how to solve this issue..

Thanks in advance.....

Comment on how to keep tracking the system command in cgi
Re: how to keep tracking the system command in cgi
by serf (Chaplain) on Feb 10, 2006 at 12:07 UTC
    If the user clicks the Stop button it will not stop the CGI script from running - it just stops the browser waiting for a reply from the webserver.

    Once the CGI program is launched it's launched, it doesn't sit there waiting to see if the client still wants an answer - it just goes away and does its job and hands the results back to the webserver to pass back to the client when it's done.

    There isn't any way for the user to stop the script from running - short of making another script specially for killing the first script (or some such functionality added to the first script).

      Well there is a way of doing this (there's always a way of doing it! ;) But this would involve forking off the installation process and using IPC or another method to communicate with the forked process.
      Is this what you are looking for? if so, consult the 'perldoc perlfork' page. There is however a limitation when used on a non-linux system like windows that doesn't support the fork system call.

      Good luck!
      Cheers,

      Rob
Re: how to keep tracking the system command in cgi
by samizdat (Vicar) on Feb 10, 2006 at 17:05 UTC
    You can run a ps -ax command and grep for your command's name in the returned output. You could also, if you need intermediate results, write (or append) progress indicators to a log file and check that file's contents.

    For example,
    • Create Directory... write 'S1' to log file
    • Write First File... write 'S2' to log file
    • Write 2nd File... write 'S3' to log file
    • Write last File... write 'Sx' to log file

    Read the file and RegEx for /Sx/. Some variant of this should help you. You could also use a SHM drop-box or other in-memory variant.

    Don Wilde
    "There's more than one level to any answer."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://529332]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-04-21 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls