Jump to content

"Your Job is Running" script


noodlebop

Recommended Posts

Visitors to my website will upload file to a simple upload.html:

 

<form action="execute.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" /><br />
<input type="submit" name="submit" value="Submit"" />
</form>

 

As you can see, the arguments are posted to execute.php. In this, I have lines that look like this:

 

	
$ob_file = fopen("../../log.txt",'w') or die ("cannot create log.txt");

function ob_file_callback($buffer)
{
global $ob_file;
fwrite($ob_file,$buffer);
}


ob_start('ob_file_callback');
system ("../../sourceShell") or die ("sourceShell fail") ;

ob_end_flush();

 

execute.php runs a shell script called 'sourceShell', which runs a fortran program on the server. execute.php outputs the 'log' of this program (that typically would appear on the terminal) on log.txt. I use the ob_file_callback function to do this.

 

When a visitor clicks 'submit' (or upon the completion of uploading), I need execute.php to echo "Your job is running..please wait". And then I want to refresh the page every 5 mins until the job finishes and the result will be shown. My problem is that, when a visitor clicks 'submit', it waits until the fortran program completely finishes (which takes a long time) before it outputs the "Your job is running..please wait". I suspect this is because of the ob_file_callback function. If I don't use that function, it seems like the log prints in real time to my browser as the program runs.

 

I do hope this make sense... and I've spent days on this wanting to tear off my hair, so it's not like I haven't googled hard. I'm completely new to web programming, so I hope you guys understand and can be patient if I don't understand.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.