Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 1st November 2006, 19:21
ColdDoT ColdDoT is offline
Senior Member
 
Join Date: Jan 2006
Location: Netherland
Posts: 178
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ColdDoT
Default Running slowed commands trough ssh2(php)

Hello

i want to restart let say apache through php
i do it with a ssh client through php, so jo get
Code:
sudo /etc/init.d/apache2 restart
Problem: it wil cut of php send of commands so it wil only stop apache but not start it.

Solution: i don't know. U?

My toughts: run the php script, it sends the command to the system but waits 2 seconds before executing the command so that apache kan finish up the sending to the client.

Is this clear enough?

Greets ColdDoT
__________________
2B or not 2B (a pro)
Reply With Quote
Sponsored Links
  #2  
Old 1st November 2006, 19:58
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,044
Thanks: 269
Thanked 154 Times in 133 Posts
Default

did you try running it in quotes?

Something like: "\sudo /etc/init.d/apache2 restart"\ or \"sudo /etc/init.d/apache2 restart\"

Last edited by edge; 1st November 2006 at 20:03.
Reply With Quote
  #3  
Old 1st November 2006, 20:02
ColdDoT ColdDoT is offline
Senior Member
 
Join Date: Jan 2006
Location: Netherland
Posts: 178
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ColdDoT
Default

Um wablieft

php script
PHP Code:
function ssh($command){
    global 
$connection$stream;
    
$stream ssh2_exec($connection$commandFALSE);
    
stream_set_blocking$streamtrue );
    
$cmd fread($stream,4096);
    
fclose($stream);
    return 
$cmd;
}
$initd trim(str_replace("\n","",ssh("locate /etc/init.d/apache")));
$reboot ssh2_exec($connectiontrim(str_replace("\n","",ssh("sudo ".$initd." restart"))), FALSE); 
The whole thing is that the command must run when my webpage is done loading
__________________
2B or not 2B (a pro)
Reply With Quote
  #4  
Old 1st November 2006, 23:43
ColdDoT ColdDoT is offline
Senior Member
 
Join Date: Jan 2006
Location: Netherland
Posts: 178
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ColdDoT
 
Default Solution

Use the
Code:
httpd -k graceful
command

then it works

Greets
__________________
2B or not 2B (a pro)
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora 4 TPS mail problem Hagforce HOWTO-Related Questions 13 10th February 2010 19:23
High Availability Samba cluster - DRBD + Heartbeat djalex Server Operation 58 25th May 2007 20:38
install Net::DNS chrno Installation/Configuration 4 5th September 2006 18:01
WARNING: services not running MicCo Installation/Configuration 31 4th September 2006 13:16


All times are GMT +2. The time now is 16:53.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.