How do I run shell script from PHP 
Author Message
 How do I run shell script from PHP

Can someone tell me why this does not go ?

/usr/local/apache/htdocs/test.php

  <?
  echo "sending\n";
  exec("./on.sh");
  exec("exit(0)");
  ?>

/usr/local/apache/htdocs/on.sh

  #!/bin/bash
  ./lptout 2

-rwxrwxrwx    1 root     root           23 Feb 13 00:41 on.sh
-rwxrwxrwx    1 root     root        12284 Feb 13 00:21 lptout

But "./on.sh" works from the command line



Sun, 31 Jul 2005 22:43:59 GMT  
 How do I run shell script from PHP

Quote:

> Can someone tell me why this does not go ?

> /usr/local/apache/htdocs/test.php

>   <?
>   echo "sending\n";
>   exec("./on.sh");
>   exec("exit(0)");
>   ?>

> /usr/local/apache/htdocs/on.sh

>   #!/bin/bash
>   ./lptout 2

> -rwxrwxrwx    1 root     root           23 Feb 13 00:41 on.sh
> -rwxrwxrwx    1 root     root        12284 Feb 13 00:21 lptout

> But "./on.sh" works from the command line

Check to see what directory PHP is operating in first.

Regards,

David

--
David Jonathan Grant
http://www.davidjonathangrant.info/



Sun, 31 Jul 2005 22:39:01 GMT  
 How do I run shell script from PHP
it is running from /usr/local/apache/htdocs/test.php
Quote:


>> Can someone tell me why this does not go ?

>> /usr/local/apache/htdocs/test.php

>>   <?
>>   echo "sending\n";
>>   exec("./on.sh");
>>   exec("exit(0)");
>>   ?>

>> /usr/local/apache/htdocs/on.sh

>>   #!/bin/bash
>>   ./lptout 2

>> -rwxrwxrwx    1 root     root           23 Feb 13 00:41 on.sh
>> -rwxrwxrwx    1 root     root        12284 Feb 13 00:21 lptout

>> But "./on.sh" works from the command line

> Check to see what directory PHP is operating in first.

> Regards,

> David



Sun, 31 Jul 2005 22:55:23 GMT  
 How do I run shell script from PHP

Quote:

> Can someone tell me why this does not go ?

> /usr/local/apache/htdocs/test.php

>   <?
>   echo "sending\n";
>   exec("./on.sh");
>   exec("exit(0)");
>   ?>

> /usr/local/apache/htdocs/on.sh

>   #!/bin/bash
>   ./lptout 2

> -rwxrwxrwx    1 root     root           23 Feb 13 00:41 on.sh
> -rwxrwxrwx    1 root     root        12284 Feb 13 00:21 lptout

> But "./on.sh" works from the command line

Try shell_exec(". /usr/local/apache/htdocs/on.sh");

--
David Jonathan Grant
http://www.davidjonathangrant.info/



Sun, 31 Jul 2005 23:06:07 GMT  
 How do I run shell script from PHP
No go

chown apache on.sh
chgrp apache on.sh

tail -f error_log

Error: Couldn't get the port at 378
Error: Couldn't get the port at 378
Error: Couldn't get the port at 378
Error: Couldn't get the port at 378
Error: Couldn't get the port at 378
Error: Couldn't get the port at 378
Error: Couldn't get the port at 378

Quote:


>> Can someone tell me why this does not go ?

>> /usr/local/apache/htdocs/test.php

>>   <?
>>   echo "sending\n";
>>   exec("./on.sh");
>>   exec("exit(0)");
>>   ?>

>> /usr/local/apache/htdocs/on.sh

>>   #!/bin/bash
>>   ./lptout 2

>> -rwxrwxrwx    1 root     root           23 Feb 13 00:41 on.sh
>> -rwxrwxrwx    1 root     root        12284 Feb 13 00:21 lptout

>> But "./on.sh" works from the command line

> Try shell_exec(". /usr/local/apache/htdocs/on.sh");



Mon, 01 Aug 2005 17:26:22 GMT  
 How do I run shell script from PHP

Quote:

> No go

> chown apache on.sh
> chgrp apache on.sh

> tail -f error_log

> Error: Couldn't get the port at 378
> Error: Couldn't get the port at 378
> Error: Couldn't get the port at 378
> Error: Couldn't get the port at 378
> Error: Couldn't get the port at 378
> Error: Couldn't get the port at 378
> Error: Couldn't get the port at 378



>>> Can someone tell me why this does not go ?

>>> /usr/local/apache/htdocs/test.php

>>>   <?
>>>   echo "sending\n";
>>>   exec("./on.sh");
>>>   exec("exit(0)");
>>>   ?>

>>> /usr/local/apache/htdocs/on.sh

>>>   #!/bin/bash
>>>   ./lptout 2

>>> -rwxrwxrwx    1 root     root           23 Feb 13 00:41 on.sh
>>> -rwxrwxrwx    1 root     root        12284 Feb 13 00:21 lptout

>>> But "./on.sh" works from the command line

>> Try shell_exec(". /usr/local/apache/htdocs/on.sh");

on.sh is world executable, so it shouldn't matter who the owner is.  Have
you tried 'su'ing to apache?

Regards,

David

--
David Jonathan Grant
http://www.davidjonathangrant.info/



Mon, 01 Aug 2005 18:07:43 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Doing bitwise AND operation in shell scripts

2. embedding php and shell cgi script..how

3. how to run from a shell script

4. how to run python script from Unix Shell?

5. how to run script in windows via C system call w/o popup dos shell

6. Converting a Shell Script to run under Python

7. running scripts on wish84 (windows) with out reopening the shell each time

8. established ways to run shell scripts from proc

9. error executing shell commands when running as cgi script

10. Run a shell script by clicking a button?

11. Shell Script (!) For Cyclically Editing/Running Python Modules

12. run shell script from tknt

 

 
Powered by phpBB® Forum Software