Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Linux shell script and PHP

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Linux shell script and PHP

Postby Yellow-Box » Thu Jan 16, 2003 11:44 am

Hi all,

I wrote a shell script:

--------------------------
#!/bin/sh
. /etc/rc.config
. /etc/rc.status
rc_reset
PPPD=/usr/sbin/named
checkproc $PPPD
rc_status -v
rc_exit
exit 0
--------------------------

the script is running on SuSE Linux 8 and works well.
It returns "..done" if process named is running and "..failed" if not.

In PHP i do:

--------------------------
$rueckgabe = exec('/var/www/Intranet/Server_Status/scripte/ssh.sh');
echo $rueckgabe;
if ( $rueckgabe == "..done" ) {
$status = "32CD32";
} else {
$status = "#ff0000";
}
--------------------------

When i run it from my browser i get $rueckgabe = "..failed", but if i run php on the command line with php script.php i get $rueckgabe = "..done".
But it must always be "..done", because the process is running.

Thanks to all who help!

Best regards,
Jan.
Yellow-Box
New php-forum User
New php-forum User
 
Posts: 2
Joined: Thu Jan 16, 2003 11:35 am

Postby Unknown » Thu Jan 16, 2003 1:36 pm

Hello to all, Im new to PHP but this might work, Please correct me if im wrong.

$rueckgabe = `/var/www/Intranet/Server_Status/scripte/ssh.sh`
Unknown
New php-forum User
New php-forum User
 
Posts: 9
Joined: Mon Jan 13, 2003 10:33 am

Re: Linux shell script and PHP

Postby WiZARD » Fri Jan 17, 2003 1:22 am

Yes you have mistake in your code, change at this:
Code: Select all
$rueckgabe = exec(`/var/www/Intranet/Server_Status/scripte/ssh.sh`);
    echo $rueckgabe;
        if ( $rueckgabe == "..done" ) {
            $status = "32CD32";
        } else {
            $status = "#ff0000";
        }      

By the way, you may use next:
Code: Select all
$rueckgabe = exec(`/var/www/Intranet/Server_Status/scripte/ssh.sh`);
       if ( $rueckgabe == false ) {
      echo ("Sorry....");
            $status = "#ff0000";
        } else {
      echo ("....Done");
            $status = "32CD32";
        }      
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol


Return to PHP coding => General

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.