Ok - This is a reply to ALL - Thanks for the great help - I now understand 
why it wasn't displaying - it was all due to caching of data at the client 
end before displaying in blocks. With some help in the comments of the php 
manual for flush() I found a nice script that uses echo str_pad('',1024); to 
help pad things out - also displays a little countdown to keep people amused 
and convinced something is happening while the service restarts! I'm LOVING 
php now - its a very simple language limited only by your imagination as to 
how you use it! My knowledge seems to be lacking more in HTML and Browser 
server relationships - I'm basing things on my background in Basic 
programming as a kid - you do Print "Hello world" and it does that instantly 
to the screen - little different with browsers!

Matt

"Myron Turner" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Matt Beechey wrote:
>> I am writing a php website for users to edit a global whitelist for Spam
>> Assassin - all is going fairly well considering I hadn't ever used php 
>> until
>> a couple of days ago. My problem is I need to restart AMAVISD-NEW after 
>> the
>> user saves the changes. I've acheived this using SUDO and giving the
>> www-data users the rights to SUDO amavisd-new. My problem is simply a 
>> user
>> friendlyness issue - below is the code I'm running -
>>
>> if(isset($_POST["SAVE"]))
>> {
>> file_put_contents("/etc/spamassassin/whitelist.cf", 
>> $_SESSION[whitelist]);
>> $_SESSION[count]=0;
>> echo "Restarting the service.........</A></P>";
>> exec('sudo /usr/sbin/amavisd-new reload');
>> echo "Service was restarted...... Returning to the main page.";
>> sleep(4)
>> echo '<meta http-equiv="refresh" content="0;URL=index.php">';
>> }
>>
>> The problem is that the Restarting the Service dialogue doesn't get
>> displayed until AFTER the Service Restarts even though it appears before 
>> the
>> shell_exec command. I've tried exec and passthru and its always the 
>> same - I
>> want it to display the "Service was restarted" - wait for 4 seconds and 
>> then
>> redirect to the main page. Instead nothing happens on screen for the 
>> browser
>> user until the service has restarted at which point they are returned to
>> index.php - its as if the exec and the sleep and the refresh to index.php
>> are all kind of running concurently.
>>
>> Can someone PLEASE tell me what I'm doing wrong - or shed light on how I
>> should do this.
>>
>> Thanks,
>>
>> Matt
>
>
> -- 
> You have to keep in mind that you are dealing with the difference in speed 
> between something that is taking place on the sever and something that is 
> being transmitted over a network.  You don't make it clear whether this is 
> an in-house site or whether it is used by people at a distance.  If the 
> latter, what you describe is not surprising at all.
>
> I've never had a reason to look into how PHP sequences events when it 
> pumps out a web page, but it's not unusual for scripts in Perl, for 
> instance, to show delays in browser output when doing something on the 
> server.  One  consideration would be how long amavisd-new takes to reload.
>
> I'm not very well-informed about hacking and security, but it would seem 
> to me that you are taking a risk by giving users root privileges to 
> restart amavisd-new.
>
>
> _____________________
> Myron Turner
> http://www.mturner.org/XML_PullParser/ 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to