Jump to content


Photo

Executar Funçao, Nao Estou Conseguindo


  • Faça o login para participar
1 reply to this topic

#1 umbu

umbu

    Normal

  • Usuários
  • 85 posts
  • Sexo:Não informado

Posted 21/12/2005, 13:39

Ola pessoal.
Peguei uma funcao no php.net mais nao estou conseguindo usar ela:

<?php
//$PID = shell_exec("cd ..; ./shoutcast/sc_serv");
//$PID = shell_exec("kill 8409");

//echo"$PID";
?> 

<?php
/**
 * @author    Ashraf M Kaabi
 * @name      Advance Linux Exec
 */
class exec {
   /**
     * Run Application in background
     *
     * @param    unknown_type $Command
     * @param    unknown_type $Priority
     * @return    PID
     */
   function background($Command, $Priority = 0){
       if($Priority)
           $PID = shell_exec("nohup nice -n $Priority $Command > /dev/null & echo $!");
       else
           $PID = shell_exec("nohup $Command > /dev/null & echo $!");
       return($PID);
   }
   /**
   * Check if the Application running !
   *
   * @param    unknown_type $PID
   * @return    boolen
   */
   function is_running($PID){
       exec("ps $PID", $ProcessState);
       return(count($ProcessState) >= 2);
   }
   /**
   * Kill Application PID
   *
   * @param  unknown_type $PID
   * @return boolen
   */
   function kill($PID){
       if(exec::is_running($PID)){
           exec("kill -KILL $PID");
           return true;
       }else return false;
   }
};

?> 

Estou tentanto usar assim:

background("cd ..; ./shoutcast/sc_serv");

isso no mesmo arquivo ficando assim:

<?php
//$PID = shell_exec("cd ..; ./shoutcast/sc_serv");
//$PID = shell_exec("kill 8409");

//echo"$PID";
?> 

<?php
/**
 * @author    Ashraf M Kaabi
 * @name      Advance Linux Exec
 */
class exec {
   /**
     * Run Application in background
     *
     * @param    unknown_type $Command
     * @param    unknown_type $Priority
     * @return    PID
     */
   function background($Command, $Priority = 0){
       if($Priority)
           $PID = shell_exec("nohup nice -n $Priority $Command > /dev/null & echo $!");
       else
           $PID = shell_exec("nohup $Command > /dev/null & echo $!");
       return($PID);
   }
   /**
   * Check if the Application running !
   *
   * @param    unknown_type $PID
   * @return    boolen
   */
   function is_running($PID){
       exec("ps $PID", $ProcessState);
       return(count($ProcessState) >= 2);
   }
   /**
   * Kill Application PID
   *
   * @param  unknown_type $PID
   * @return boolen
   */
   function kill($PID){
       if(exec::is_running($PID)){
           exec("kill -KILL $PID");
           return true;
       }else return false;
   }
};

background("cd ..; ./shoutcast/sc_serv");
?> 

so que da erro e exibe esta msg: Fatal error: Call to undefined function: background() in /home/login/public_html/ssh.php on line 52

estou fazendo certo?
Eu apoio a Ong Desapareceu!
Apoie você também.
http://forum.wmonlin...howtopic=130640

#2 Fábio Luciano

Fábio Luciano

    Ativo

  • Usuários
  • 309 posts
  • Sexo:Masculino
  • Localidade:Santa Maria / DF
  • Interesses:Ah eu gosto de tudo :D

Posted 21/12/2005, 13:55

como você quer chamar uma função sem primeiro cahar a classe a qual ela está subordinada?

$CallClass = new exec;
$CallClass->background("cd ..; ./shoutcast/sc_serv");





0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq