Re: [PHP] exec and system do not work

2013-08-27 Thread Daniel Brown
On Sun, Aug 25, 2013 at 11:41 PM, Ethan Rosenberg
 wrote:
> Dear List -
>
> I'm lost on this one -
>
> This works -
>
> $out = system("ls -l ",$retvals);
> printf("%s", $out);
>
> This does -
>
> echo exec("ls -l");
>
> This does not -
>
> if( !file_exists("/var/www/orders.txt"));
> {
>$out = system("touch /var/www/orders.txt", $ret);
>$out2 = system("chmod 766 /var/www/orders.txt", $ret);
>echo 'file2';
>echo file_exists("/var/www/orders.txt");
> }



-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] exec and system do not work

2013-08-27 Thread Jim Giner

On 8/26/2013 5:01 PM, Ethan Rosenberg, PhD wrote:


On 08/26/2013 03:28 PM, Jim Giner wrote:

On 8/26/2013 2:41 PM, Ethan Rosenberg wrote:


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple  hat am 26. August 2013 um
08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 wrote:


Dear List -

I'm lost on this one -

This works -

$out = system("ls -l ",$retvals);
printf("%s", $out);

This does -

echo exec("ls -l");


Please show the output of the directory listing.
Please us "ls -la"



This does not -

if( !file_exists("/var/www/orders.txt"));
{
$out = system("touch /var/www/orders.txt", $ret);


Maybe you don't have write permissions on the folder?


$out2 = system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

and this does not -

if( !file_exists("/var/www/orders.txt"));
{
exec("touch /var/www/orders.txt");
exec("chmod 766 /var/www/orders.txt");
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

Ethan




When you say "does not work", can you show what is actually not
working? I
believe the exec and system functions are likely working just fine,
but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

 > Please show the output of the directory listing.
 > Please us "ls -la"

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything
works.


 >> When you say "does not work", can you show what is actually not
working? I
 >> believe the exec and system functions are likely working just fine,
but that
 >> the commands you've passed to them may not be.

Here are my commands.

if( !file_exists("/var/www/orders.txt"));
{
echo system("touch /var/www/orders.txt", $ret);
echo system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

If I now try a ls from the command line, the return is
  cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






Ethan - YOU'RE DOING IT AGAIN!!!

Either you are not using error checking AGAIN!!
OR
You are showing us re-typed in code that YOU DIDN"T ACTUALLY RUN.

I've told you multiple times that you need to do these two things and
you are back at it again.

The sample php above has plain simple syntax errors that would keep it
from running, which error checking would tell you IF YOU RAN IT.



Jim -

Thank you.

I don't totally understand your reply ...

but I will try to answer

The code is taken from an operating program.  My error checking is set
to maximum sensitivity.

If you would point out my syntax errors, I will fix them.

TIA

Ethan


you have semis after your if lines - therefore no logic gets executed.

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



Re: [PHP] exec and system do not work

2013-08-26 Thread David Robley
"Ethan Rosenberg, PhD" wrote:

> 
> 
> Ethan Rosenberg, PhD
> /Pres/CEO/
> *Hygeia Biomedical Research, Inc*
> 2 Cameo Ridge Road
> Monsey, NY 10952
> T: 845 352-3908
> F: 845 352-7566
> erosenb...@hygeiabiomedical.com
> 
> On 08/26/2013 07:33 PM, David Robley wrote:
>> Ethan Rosenberg wrote:
>>
>>>
>>> On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:


> Tamara Temple  hat am 26. August 2013 um
> 08:33 geschrieben:
>
>
>
> On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
>  wrote:
>
>> Dear List -
>>
>> I'm lost on this one -
>>
>> This works -
>>
>> $out = system("ls -l ",$retvals);
>> printf("%s", $out);
>>
>> This does -
>>
>> echo exec("ls -l");

 Please show the output of the directory listing.
 Please us "ls -la"

>>
>> This does not -
>>
>> if( !file_exists("/var/www/orders.txt"));
>> {
>>  $out = system("touch /var/www/orders.txt", $ret);

 Maybe you don't have write permissions on the folder?

>>  $out2 = system("chmod 766 /var/www/orders.txt", $ret);
>>  echo 'file2';
>>  echo file_exists("/var/www/orders.txt");
>> }
>>
>> and this does not -
>>
>> if( !file_exists("/var/www/orders.txt"));
>> {
>>  exec("touch /var/www/orders.txt");
>>  exec("chmod 766 /var/www/orders.txt");
>>  echo 'file2';
>>  echo file_exists("/var/www/orders.txt");
>> }
>>
>> Ethan
>>
>>
>
> When you say "does not work", can you show what is actually not
> working? I believe the exec and system functions are likely working
> just fine, but that the commands you've passed to them may not be.
>
>
>
 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3

 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz

 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal

 http://www.behnke.biz

>>>
>>> Tamara -
>>>
>>>   > Please show the output of the directory listing.
>>>   > Please us "ls -la"
>>>
>>> echo exec('ls -la orders.txt');
>>>
>>> -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt
>>>
>>>
>>> Maybe you don't have write permissions on the folder?
>>>
>>> If I perform the touch and chmod from the command line, everything
>>> works.
>>>
>>>
>>>   >> When you say "does not work", can you show what is actually not
>>> working? I
>>>   >> believe the exec and system functions are likely working just fine,
>>> but that
>>>   >> the commands you've passed to them may not be.
>>>
>>> Here are my commands.
>>>
>>> if( !file_exists("/var/www/orders.txt"));
>>> {
>>> echo system("touch /var/www/orders.txt", $ret);
>>> echo system("chmod 766 /var/www/orders.txt", $ret);
>>> echo 'file2';
>>> echo file_exists("/var/www/orders.txt");
>>> }
>>>
>>> If I now try a ls from the command line, the return is
>>>cannot access /var/www/orders.txt: No such file or directory
>>>
>>> The ls -la  works because the file was created from the command line.
>>>
>>> TIA
>>>
>>> Ethan
>>
>> Note that touch and chmod don't return any output, so echoing the result
>> of a system call for those commands will give an empty string.
>>
>> You should be checking the values of $ret for each execution of system to
>> see whether the command was successful or not - the return status of the
>> executed command will be written to this variable. I'd guess that touch
>> is returning 13 - permission denied.
>>
>> if( !file_exists("/var/www/orders.txt"))
>> {
>>system("touch /var/www/orders.txt", $ret1);
>>echo 'touch returned '.$ret1.' /';
>>system("chmod 766 /var/www/orders.txt", $ret2);
>>echo 'chmod returned ' .$ret2.' /';
>>echo 'file2';
>> echo file_exists("/var/www/orders.txt"); }
>>
>> Check the permissions for directory /var/www; you'll probably find it is
>> writable by the user you log on as, but not by the user that apache/php
>> runs as, which is often www - a user with limited privileges.
>>
>> As other(s) have pointed out, there are php functions to do what you want
>> without introducing the possible insecurities involved with system et al.
>>
> 
> David -
> 
> touch returned 1
>   /chmod returned 1
> 

Non-zero return value indicates an error; touch failed and as a result there 
is no file to chmod, hence chmod also failed.

> rosenberg:/var/www# ls orders.txt
> ls: cannot access orders.txt: No such file or directory
> 
> rosenberg:/var# ls -ld www
> drwxr-xr-x 37 ethan ethan 20480 Aug 26 20:15 www

/var/www is only writeable by the user ethan
-- 
Cheers
David Robley

INTERLACE: To tie two boots together.


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



Re: [PHP] exec and system do not work

2013-08-26 Thread Jasper Kips
Ethan,
A return code of not 0 means an error occured.
Probably /var/www is not writable. Test that one by doing this:
$a = is_writable("/var/www);
var_dump($a);
If that says anything else than (boolean) TRUE, you can't write in the 
directory. 


Sincerely,

Jasper Kips


Op 27 aug. 2013, om 02:32 heeft "Ethan Rosenberg, PhD" 
 het volgende geschreven:

> 
> 
> Ethan Rosenberg, PhD
> /Pres/CEO/
> *Hygeia Biomedical Research, Inc*
> 2 Cameo Ridge Road
> Monsey, NY 10952
> T: 845 352-3908
> F: 845 352-7566
> erosenb...@hygeiabiomedical.com
> 
> On 08/26/2013 07:33 PM, David Robley wrote:
>> Ethan Rosenberg wrote:
>> 
>>> 
>>> On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:
 
 
> Tamara Temple  hat am 26. August 2013 um 08:33
> geschrieben:
> 
> 
> 
> On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
>  wrote:
> 
>> Dear List -
>> 
>> I'm lost on this one -
>> 
>> This works -
>> 
>> $out = system("ls -l ",$retvals);
>> printf("%s", $out);
>> 
>> This does -
>> 
>> echo exec("ls -l");
 
 Please show the output of the directory listing.
 Please us "ls -la"
 
>> 
>> This does not -
>> 
>> if( !file_exists("/var/www/orders.txt"));
>> {
>> $out = system("touch /var/www/orders.txt", $ret);
 
 Maybe you don't have write permissions on the folder?
 
>> $out2 = system("chmod 766 /var/www/orders.txt", $ret);
>> echo 'file2';
>> echo file_exists("/var/www/orders.txt");
>> }
>> 
>> and this does not -
>> 
>> if( !file_exists("/var/www/orders.txt"));
>> {
>> exec("touch /var/www/orders.txt");
>> exec("chmod 766 /var/www/orders.txt");
>> echo 'file2';
>> echo file_exists("/var/www/orders.txt");
>> }
>> 
>> Ethan
>> 
>> 
> 
> When you say "does not work", can you show what is actually not working?
> I believe the exec and system functions are likely working just fine,
> but that the commands you've passed to them may not be.
> 
> 
> 
 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3
 
 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz
 
 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal
 
 http://www.behnke.biz
 
>>> 
>>> Tamara -
>>> 
>>>  > Please show the output of the directory listing.
>>>  > Please us "ls -la"
>>> 
>>> echo exec('ls -la orders.txt');
>>> 
>>> -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt
>>> 
>>> 
>>> Maybe you don't have write permissions on the folder?
>>> 
>>> If I perform the touch and chmod from the command line, everything works.
>>> 
>>> 
>>>  >> When you say "does not work", can you show what is actually not
>>> working? I
>>>  >> believe the exec and system functions are likely working just fine,
>>> but that
>>>  >> the commands you've passed to them may not be.
>>> 
>>> Here are my commands.
>>> 
>>> if( !file_exists("/var/www/orders.txt"));
>>> {
>>> echo system("touch /var/www/orders.txt", $ret);
>>> echo system("chmod 766 /var/www/orders.txt", $ret);
>>> echo 'file2';
>>> echo file_exists("/var/www/orders.txt");
>>> }
>>> 
>>> If I now try a ls from the command line, the return is
>>>   cannot access /var/www/orders.txt: No such file or directory
>>> 
>>> The ls -la  works because the file was created from the command line.
>>> 
>>> TIA
>>> 
>>> Ethan
>> 
>> Note that touch and chmod don't return any output, so echoing the result of
>> a system call for those commands will give an empty string.
>> 
>> You should be checking the values of $ret for each execution of system to
>> see whether the command was successful or not - the return status of the
>> executed command will be written to this variable. I'd guess that touch is
>> returning 13 - permission denied.
>> 
>> if( !file_exists("/var/www/orders.txt"))
>> {
>>   system("touch /var/www/orders.txt", $ret1);
>>   echo 'touch returned '.$ret1.' /';
>>   system("chmod 766 /var/www/orders.txt", $ret2);
>>   echo 'chmod returned ' .$ret2.' /';
>>   echo 'file2';
>> echo file_exists("/var/www/orders.txt"); }
>> 
>> Check the permissions for directory /var/www; you'll probably find it is
>> writable by the user you log on as, but not by the user that apache/php runs
>> as, which is often www - a user with limited privileges.
>> 
>> As other(s) have pointed out, there are php functions to do what you want
>> without introducing the possible insecurities involved with system et al.
>> 
> 
> David -
> 
> touch returned 1
> /chmod returned 1
> 
> rosenberg:/var/www# ls orders.txt
> ls: cannot access orders.txt: No such file or directory
> 
> rosenberg:/var# ls -ld www
> drwxr-xr-x 37 ethan ethan 20480 Aug 26 20:15 www
> 
> TIA
> 
> Ethan
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--
P

Re: [PHP] exec and system do not work

2013-08-26 Thread Ethan Rosenberg, PhD



Ethan Rosenberg, PhD
/Pres/CEO/
*Hygeia Biomedical Research, Inc*
2 Cameo Ridge Road
Monsey, NY 10952
T: 845 352-3908
F: 845 352-7566
erosenb...@hygeiabiomedical.com

On 08/26/2013 07:33 PM, David Robley wrote:

Ethan Rosenberg wrote:



On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple  hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 wrote:


Dear List -

I'm lost on this one -

This works -

$out = system("ls -l ",$retvals);
printf("%s", $out);

This does -

echo exec("ls -l");


Please show the output of the directory listing.
Please us "ls -la"



This does not -

if( !file_exists("/var/www/orders.txt"));
{
 $out = system("touch /var/www/orders.txt", $ret);


Maybe you don't have write permissions on the folder?


 $out2 = system("chmod 766 /var/www/orders.txt", $ret);
 echo 'file2';
 echo file_exists("/var/www/orders.txt");
}

and this does not -

if( !file_exists("/var/www/orders.txt"));
{
 exec("touch /var/www/orders.txt");
 exec("chmod 766 /var/www/orders.txt");
 echo 'file2';
 echo file_exists("/var/www/orders.txt");
}

Ethan




When you say "does not work", can you show what is actually not working?
I believe the exec and system functions are likely working just fine,
but that the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

  > Please show the output of the directory listing.
  > Please us "ls -la"

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything works.


  >> When you say "does not work", can you show what is actually not
working? I
  >> believe the exec and system functions are likely working just fine,
but that
  >> the commands you've passed to them may not be.

Here are my commands.

if( !file_exists("/var/www/orders.txt"));
{
echo system("touch /var/www/orders.txt", $ret);
echo system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

If I now try a ls from the command line, the return is
   cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan


Note that touch and chmod don't return any output, so echoing the result of
a system call for those commands will give an empty string.

You should be checking the values of $ret for each execution of system to
see whether the command was successful or not - the return status of the
executed command will be written to this variable. I'd guess that touch is
returning 13 - permission denied.

if( !file_exists("/var/www/orders.txt"))
{
   system("touch /var/www/orders.txt", $ret1);
   echo 'touch returned '.$ret1.' /';
   system("chmod 766 /var/www/orders.txt", $ret2);
   echo 'chmod returned ' .$ret2.' /';
   echo 'file2';
echo file_exists("/var/www/orders.txt"); }

Check the permissions for directory /var/www; you'll probably find it is
writable by the user you log on as, but not by the user that apache/php runs
as, which is often www - a user with limited privileges.

As other(s) have pointed out, there are php functions to do what you want
without introducing the possible insecurities involved with system et al.



David -

touch returned 1
 /chmod returned 1

rosenberg:/var/www# ls orders.txt
ls: cannot access orders.txt: No such file or directory

rosenberg:/var# ls -ld www
drwxr-xr-x 37 ethan ethan 20480 Aug 26 20:15 www

TIA

Ethan

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



Re: [PHP] exec and system do not work

2013-08-26 Thread David Robley
Ethan Rosenberg wrote:

> 
> On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:
>>
>>
>>> Tamara Temple  hat am 26. August 2013 um 08:33
>>> geschrieben:
>>>
>>>
>>>
>>> On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
>>>  wrote:
>>>
 Dear List -

 I'm lost on this one -

 This works -

 $out = system("ls -l ",$retvals);
 printf("%s", $out);

 This does -

 echo exec("ls -l");
>>
>> Please show the output of the directory listing.
>> Please us "ls -la"
>>

 This does not -

 if( !file_exists("/var/www/orders.txt"));
 {
 $out = system("touch /var/www/orders.txt", $ret);
>>
>> Maybe you don't have write permissions on the folder?
>>
 $out2 = system("chmod 766 /var/www/orders.txt", $ret);
 echo 'file2';
 echo file_exists("/var/www/orders.txt");
 }

 and this does not -

 if( !file_exists("/var/www/orders.txt"));
 {
 exec("touch /var/www/orders.txt");
 exec("chmod 766 /var/www/orders.txt");
 echo 'file2';
 echo file_exists("/var/www/orders.txt");
 }

 Ethan


>>>
>>> When you say "does not work", can you show what is actually not working?
>>> I believe the exec and system functions are likely working just fine,
>>> but that the commands you've passed to them may not be.
>>>
>>>
>>>
>> --
>> Marco Behnke
>> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
>> Zend Certified Engineer PHP 5.3
>>
>> Tel.: 0174 / 9722336
>> e-Mail: ma...@behnke.biz
>>
>> Softwaretechnik Behnke
>> Heinrich-Heine-Str. 7D
>> 21218 Seevetal
>>
>> http://www.behnke.biz
>>
> 
> Tamara -
> 
>  > Please show the output of the directory listing.
>  > Please us "ls -la"
> 
> echo exec('ls -la orders.txt');
> 
> -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt
> 
> 
> Maybe you don't have write permissions on the folder?
> 
> If I perform the touch and chmod from the command line, everything works.
> 
> 
>  >> When you say "does not work", can you show what is actually not
> working? I
>  >> believe the exec and system functions are likely working just fine,
> but that
>  >> the commands you've passed to them may not be.
> 
> Here are my commands.
> 
> if( !file_exists("/var/www/orders.txt"));
> {
> echo system("touch /var/www/orders.txt", $ret);
> echo system("chmod 766 /var/www/orders.txt", $ret);
> echo 'file2';
> echo file_exists("/var/www/orders.txt");
> }
> 
> If I now try a ls from the command line, the return is
>   cannot access /var/www/orders.txt: No such file or directory
> 
> The ls -la  works because the file was created from the command line.
> 
> TIA
> 
> Ethan

Note that touch and chmod don't return any output, so echoing the result of 
a system call for those commands will give an empty string.

You should be checking the values of $ret for each execution of system to 
see whether the command was successful or not - the return status of the 
executed command will be written to this variable. I'd guess that touch is 
returning 13 - permission denied.

if( !file_exists("/var/www/orders.txt"))
{
  system("touch /var/www/orders.txt", $ret1);
  echo 'touch returned '.$ret1.' /';
  system("chmod 766 /var/www/orders.txt", $ret2);
  echo 'chmod returned ' .$ret2.' /';
  echo 'file2';
echo file_exists("/var/www/orders.txt"); }

Check the permissions for directory /var/www; you'll probably find it is 
writable by the user you log on as, but not by the user that apache/php runs 
as, which is often www - a user with limited privileges.

As other(s) have pointed out, there are php functions to do what you want 
without introducing the possible insecurities involved with system et al.

-- 
Cheers
David Robley

"Don't try to pull the wool over my eyes," Tom said sheepishly.


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



Re: [PHP] exec and system do not work

2013-08-26 Thread Ethan Rosenberg, PhD


On 08/26/2013 03:28 PM, Jim Giner wrote:

On 8/26/2013 2:41 PM, Ethan Rosenberg wrote:


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple  hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 wrote:


Dear List -

I'm lost on this one -

This works -

$out = system("ls -l ",$retvals);
printf("%s", $out);

This does -

echo exec("ls -l");


Please show the output of the directory listing.
Please us "ls -la"



This does not -

if( !file_exists("/var/www/orders.txt"));
{
$out = system("touch /var/www/orders.txt", $ret);


Maybe you don't have write permissions on the folder?


$out2 = system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

and this does not -

if( !file_exists("/var/www/orders.txt"));
{
exec("touch /var/www/orders.txt");
exec("chmod 766 /var/www/orders.txt");
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

Ethan




When you say "does not work", can you show what is actually not
working? I
believe the exec and system functions are likely working just fine,
but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

 > Please show the output of the directory listing.
 > Please us "ls -la"

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything works.


 >> When you say "does not work", can you show what is actually not
working? I
 >> believe the exec and system functions are likely working just fine,
but that
 >> the commands you've passed to them may not be.

Here are my commands.

if( !file_exists("/var/www/orders.txt"));
{
echo system("touch /var/www/orders.txt", $ret);
echo system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

If I now try a ls from the command line, the return is
  cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






Ethan - YOU'RE DOING IT AGAIN!!!

Either you are not using error checking AGAIN!!
OR
You are showing us re-typed in code that YOU DIDN"T ACTUALLY RUN.

I've told you multiple times that you need to do these two things and
you are back at it again.

The sample php above has plain simple syntax errors that would keep it
from running, which error checking would tell you IF YOU RAN IT.



Jim -

Thank you.

I don't totally understand your reply ...

but I will try to answer

The code is taken from an operating program.  My error checking is set 
to maximum sensitivity.


If you would point out my syntax errors, I will fix them.

TIA

Ethan


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



Re: [PHP] exec and system do not work

2013-08-26 Thread Tamara Temple

On Aug 26, 2013, at 1:41 PM, Ethan Rosenberg  
wrote:
> On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:
>>> Tamara Temple  hat am 26. August 2013 um 08:33
>>> geschrieben:
>>> 
>>> 
>>> 
>>> On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
>>>  wrote:
>>> 
 Dear List -
 
 I'm lost on this one -
 
 This works -
 
 $out = system("ls -l ",$retvals);
 printf("%s", $out);
 
 This does -
 
 echo exec("ls -l");
>> 
>> Please show the output of the directory listing.
>> Please us "ls -la"
>> 
 
 This does not -
 
 if( !file_exists("/var/www/orders.txt"));
 {
$out = system("touch /var/www/orders.txt", $ret);
>> 
>> Maybe you don't have write permissions on the folder?
>> 
$out2 = system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
 }
 
 and this does not -
 
 if( !file_exists("/var/www/orders.txt"));
 {
exec("touch /var/www/orders.txt");
exec("chmod 766 /var/www/orders.txt");
echo 'file2';
echo file_exists("/var/www/orders.txt");
 }
 
 Ethan
 
 
>>> 
>>> When you say "does not work", can you show what is actually not working? I
>>> believe the exec and system functions are likely working just fine, but that
>>> the commands you've passed to them may not be.
>>> 
>>> 
>>> 
>> --
>> Marco Behnke
>> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
>> Zend Certified Engineer PHP 5.3
>> 
>> Tel.: 0174 / 9722336
>> e-Mail: ma...@behnke.biz
>> 
>> Softwaretechnik Behnke
>> Heinrich-Heine-Str. 7D
>> 21218 Seevetal
>> 
>> http://www.behnke.biz
>> 
> 
> Tamara -

You're replying to me about something someone else asked you.

> 
> > Please show the output of the directory listing.
> > Please us "ls -la"
> 
> echo exec('ls -la orders.txt');
> 
> -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt
> 
> 
> Maybe you don't have write permissions on the folder?
> 
> If I perform the touch and chmod from the command line, everything works.
> 
> 
> >> When you say "does not work", can you show what is actually not working? I
> >> believe the exec and system functions are likely working just fine, but 
> >> that
> >> the commands you've passed to them may not be.
> 
> Here are my commands.
> 
> if( !file_exists("/var/www/orders.txt"));
> {
> echo system("touch /var/www/orders.txt", $ret);
> echo system("chmod 766 /var/www/orders.txt", $ret);
> echo 'file2';
> echo file_exists("/var/www/orders.txt");
> }
> 
> If I now try a ls from the command line, the return is
> cannot access /var/www/orders.txt: No such file or directory
> 
> The ls -la  works because the file was created from the command line.
> 
> TIA
> 
> Ethan
> 
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



Re: [PHP] exec and system do not work

2013-08-26 Thread ma...@behnke.biz


> Ethan Rosenberg  hat am 26. August 2013 um
> 20:41 geschrieben:

>
>  > Please show the output of the directory listing.
>  > Please us "ls -la"
>
> echo exec('ls -la orders.txt');
>
> -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt

Please supply the complete output. Especially the rights for . and ..

> Maybe you don't have write permissions on the folder?
>
> If I perform the touch and chmod from the command line, everything works.

cli and ww are different users.

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



Re: [PHP] exec and system do not work

2013-08-26 Thread Jim Giner

On 8/26/2013 2:41 PM, Ethan Rosenberg wrote:


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple  hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 wrote:


Dear List -

I'm lost on this one -

This works -

$out = system("ls -l ",$retvals);
printf("%s", $out);

This does -

echo exec("ls -l");


Please show the output of the directory listing.
Please us "ls -la"



This does not -

if( !file_exists("/var/www/orders.txt"));
{
$out = system("touch /var/www/orders.txt", $ret);


Maybe you don't have write permissions on the folder?


$out2 = system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

and this does not -

if( !file_exists("/var/www/orders.txt"));
{
exec("touch /var/www/orders.txt");
exec("chmod 766 /var/www/orders.txt");
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

Ethan




When you say "does not work", can you show what is actually not
working? I
believe the exec and system functions are likely working just fine,
but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

 > Please show the output of the directory listing.
 > Please us "ls -la"

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything works.


 >> When you say "does not work", can you show what is actually not
working? I
 >> believe the exec and system functions are likely working just fine,
but that
 >> the commands you've passed to them may not be.

Here are my commands.

if( !file_exists("/var/www/orders.txt"));
{
echo system("touch /var/www/orders.txt", $ret);
echo system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

If I now try a ls from the command line, the return is
  cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






Ethan - YOU'RE DOING IT AGAIN!!!

Either you are not using error checking AGAIN!!
OR
You are showing us re-typed in code that YOU DIDN"T ACTUALLY RUN.

I've told you multiple times that you need to do these two things and 
you are back at it again.


The sample php above has plain simple syntax errors that would keep it 
from running, which error checking would tell you IF YOU RAN IT.


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



Re: [PHP] exec and system do not work

2013-08-26 Thread Ethan Rosenberg


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple  hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 wrote:


Dear List -

I'm lost on this one -

This works -

$out = system("ls -l ",$retvals);
printf("%s", $out);

This does -

echo exec("ls -l");


Please show the output of the directory listing.
Please us "ls -la"



This does not -

if( !file_exists("/var/www/orders.txt"));
{
$out = system("touch /var/www/orders.txt", $ret);


Maybe you don't have write permissions on the folder?


$out2 = system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

and this does not -

if( !file_exists("/var/www/orders.txt"));
{
exec("touch /var/www/orders.txt");
exec("chmod 766 /var/www/orders.txt");
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

Ethan




When you say "does not work", can you show what is actually not working? I
believe the exec and system functions are likely working just fine, but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

> Please show the output of the directory listing.
> Please us "ls -la"

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything works.


>> When you say "does not work", can you show what is actually not 
working? I
>> believe the exec and system functions are likely working just fine, 
but that

>> the commands you've passed to them may not be.

Here are my commands.

if( !file_exists("/var/www/orders.txt"));
{
echo system("touch /var/www/orders.txt", $ret);
echo system("chmod 766 /var/www/orders.txt", $ret);
echo 'file2';
echo file_exists("/var/www/orders.txt");
}

If I now try a ls from the command line, the return is
 cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






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



Re: [PHP] exec and system do not work

2013-08-26 Thread ma...@behnke.biz


> Tamara Temple  hat am 26. August 2013 um 08:33
> geschrieben:
>
>
>
> On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
>  wrote:
>
> > Dear List -
> >
> > I'm lost on this one -
> >
> > This works -
> >
> > $out = system("ls -l ",$retvals);
> > printf("%s", $out);
> >
> > This does -
> >
> > echo exec("ls -l");

Please show the output of the directory listing.
Please us "ls -la"

> >
> > This does not -
> >
> > if( !file_exists("/var/www/orders.txt"));
> > {
> >   $out = system("touch /var/www/orders.txt", $ret);

Maybe you don't have write permissions on the folder?

> >   $out2 = system("chmod 766 /var/www/orders.txt", $ret);
> >   echo 'file2';
> >   echo file_exists("/var/www/orders.txt");
> > }
> >
> > and this does not -
> >
> > if( !file_exists("/var/www/orders.txt"));
> > {
> >   exec("touch /var/www/orders.txt");
> >   exec("chmod 766 /var/www/orders.txt");
> >   echo 'file2';
> >   echo file_exists("/var/www/orders.txt");
> > }
> >
> > Ethan
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> When you say "does not work", can you show what is actually not working? I
> believe the exec and system functions are likely working just fine, but that
> the commands you've passed to them may not be.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

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



Re: [PHP] exec and system do not work

2013-08-25 Thread Tamara Temple

On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg  
wrote:

> Dear List -
> 
> I'm lost on this one -
> 
> This works -
> 
> $out = system("ls -l ",$retvals);
> printf("%s", $out);
> 
> This does -
> 
> echo exec("ls -l");
> 
> This does not -
> 
> if( !file_exists("/var/www/orders.txt"));
> {
>   $out = system("touch /var/www/orders.txt", $ret);
>   $out2 = system("chmod 766 /var/www/orders.txt", $ret);
>   echo 'file2';
>   echo file_exists("/var/www/orders.txt");
> }
> 
> and this does not -
> 
> if( !file_exists("/var/www/orders.txt"));
> {
>   exec("touch /var/www/orders.txt");
>   exec("chmod 766 /var/www/orders.txt");
>   echo 'file2';
>   echo file_exists("/var/www/orders.txt");
> }
> 
> Ethan
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

When you say "does not work", can you show what is actually not working? I 
believe the exec and system functions are likely working just fine, but that 
the commands you've passed to them may not be.



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



Re: [PHP] exec and system do not work

2013-08-25 Thread Robert Cummings

On 13-08-25 11:41 PM, Ethan Rosenberg wrote:

Dear List -

I'm lost on this one -

This works -

$out = system("ls -l ",$retvals);
printf("%s", $out);

This does -

echo exec("ls -l");

This does not -

if( !file_exists("/var/www/orders.txt"));
{
 $out = system("touch /var/www/orders.txt", $ret);
 $out2 = system("chmod 766 /var/www/orders.txt", $ret);
 echo 'file2';
 echo file_exists("/var/www/orders.txt");
}

and this does not -

if( !file_exists("/var/www/orders.txt"));
{
 exec("touch /var/www/orders.txt");
 exec("chmod 766 /var/www/orders.txt");
 echo 'file2';
 echo file_exists("/var/www/orders.txt");
}

Ethan


Hi Ethan,

Is there a reason you're using shell commands to achieve the following:



Also, why are you setting the executable bit on a text file? :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] exec and system do not work

2013-08-25 Thread Sorin Badea
*/var/www* is usually under *www* user. It may be a permissions problem.


On Mon, Aug 26, 2013 at 6:41 AM, Ethan Rosenberg <
erosenb...@hygeiabiomedical.com> wrote:

> Dear List -
>
> I'm lost on this one -
>
> This works -
>
> $out = system("ls -l ",$retvals);
> printf("%s", $out);
>
> This does -
>
> echo exec("ls -l");
>
> This does not -
>
> if( !file_exists("/var/www/orders.**txt"));
> {
>$out = system("touch /var/www/orders.txt", $ret);
>$out2 = system("chmod 766 /var/www/orders.txt", $ret);
>echo 'file2';
>echo file_exists("/var/www/orders.**txt");
> }
>
> and this does not -
>
> if( !file_exists("/var/www/orders.**txt"));
> {
>exec("touch /var/www/orders.txt");
>exec("chmod 766 /var/www/orders.txt");
>echo 'file2';
>echo file_exists("/var/www/orders.**txt");
> }
>
> Ethan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Sorin Badea - Software Engineer


[PHP] exec and system do not work

2013-08-25 Thread Ethan Rosenberg

Dear List -

I'm lost on this one -

This works -

$out = system("ls -l ",$retvals);
printf("%s", $out);

This does -

echo exec("ls -l");

This does not -

if( !file_exists("/var/www/orders.txt"));
{
   $out = system("touch /var/www/orders.txt", $ret);
   $out2 = system("chmod 766 /var/www/orders.txt", $ret);
   echo 'file2';
   echo file_exists("/var/www/orders.txt");
}

and this does not -

if( !file_exists("/var/www/orders.txt"));
{
   exec("touch /var/www/orders.txt");
   exec("chmod 766 /var/www/orders.txt");
   echo 'file2';
   echo file_exists("/var/www/orders.txt");
}

Ethan

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



Re: [PHP] What needs to configure to run php exec for socket connection?

2013-01-27 Thread Ashley Sheridan
On Sun, 2013-01-27 at 21:40 +1100, jupiter wrote:

> On 1/27/13, Ashley Sheridan  wrote:
> > On Sun, 2013-01-27 at 03:45 -0600, tamouse mailing lists wrote:
> >
> >> On Sun, Jan 27, 2013 at 3:10 AM, jupiter  wrote:
> >> > Hi,
> >> >
> >> > I  have a client.php which calls an external python socket client
> >> > program exec("Client.py"), the Client.py calls
> >> > sockobj.connect(("localhost", 6)) to connect socket.
> >> >
> >> > If I run the client.php from Linux command line $ ./client.php, it
> >> > works find, no problem at all.
> >> >
> >> > But when I run it from web page http://localhost/client.php, it could
> >> > not connect to socket at following exception in python
> >> > sockobj.connect(("localhost", 6)):
> >> >
> >> > "sockobj.connect Errno 13 Permission denied"
> >> >
> >> > Why it can run from command line, but cannot make socket connection
> >> > from web? Does it need some kind of configuration in php or apache?
> >> > Appreciate any tips and clues.
> >> >
> >> > Thank you.
> >> >
> >> > Kind regards.
> >> > I am puzzled by
> >>
> >> First question: why use a separate program and language to call a
> >> socket? PHP has two ways of doing it, using the Socket extension and
> >> using the Stream extension. The Stream extension is a little nicer as
> >> you just use standard PHP file functions on it.
> >>
> >> To look here, though, you might want to look at the permissions on
> >> client.py to make sure it as well as the requisite paths to get to the
> >> script are readable and executable by the user running your webserver,
> >> or alternatively, your php scripts if running something like fcgi.
> >>
> >
> >
> > I'll take a bet that the Apache server is running as a different user
> > from your login, and doesn't have permissions to open sockets. You could
> > either give the Apache user permissions, or put the exec call as part of
> > an argument of sudo.
> 
> Well, it is apache for both user id and group id if you are running
> from web server. The problem is not which user account, I can run it
> without any problems from command line in any user accounts, the
> problem is it got permission denied when you run from web server.
> 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >


So you've logged on/sudo'd as the Apache user and the command runs?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] What needs to configure to run php exec for socket connection?

2013-01-27 Thread jupiter
On 1/27/13, Ashley Sheridan  wrote:
> On Sun, 2013-01-27 at 03:45 -0600, tamouse mailing lists wrote:
>
>> On Sun, Jan 27, 2013 at 3:10 AM, jupiter  wrote:
>> > Hi,
>> >
>> > I  have a client.php which calls an external python socket client
>> > program exec("Client.py"), the Client.py calls
>> > sockobj.connect(("localhost", 6)) to connect socket.
>> >
>> > If I run the client.php from Linux command line $ ./client.php, it
>> > works find, no problem at all.
>> >
>> > But when I run it from web page http://localhost/client.php, it could
>> > not connect to socket at following exception in python
>> > sockobj.connect(("localhost", 6)):
>> >
>> > "sockobj.connect Errno 13 Permission denied"
>> >
>> > Why it can run from command line, but cannot make socket connection
>> > from web? Does it need some kind of configuration in php or apache?
>> > Appreciate any tips and clues.
>> >
>> > Thank you.
>> >
>> > Kind regards.
>> > I am puzzled by
>>
>> First question: why use a separate program and language to call a
>> socket? PHP has two ways of doing it, using the Socket extension and
>> using the Stream extension. The Stream extension is a little nicer as
>> you just use standard PHP file functions on it.
>>
>> To look here, though, you might want to look at the permissions on
>> client.py to make sure it as well as the requisite paths to get to the
>> script are readable and executable by the user running your webserver,
>> or alternatively, your php scripts if running something like fcgi.
>>
>
>
> I'll take a bet that the Apache server is running as a different user
> from your login, and doesn't have permissions to open sockets. You could
> either give the Apache user permissions, or put the exec call as part of
> an argument of sudo.

Well, it is apache for both user id and group id if you are running
from web server. The problem is not which user account, I can run it
without any problems from command line in any user accounts, the
problem is it got permission denied when you run from web server.

> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

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



Re: [PHP] What needs to configure to run php exec for socket connection?

2013-01-27 Thread jupiter
On 1/27/13, tamouse mailing lists  wrote:
> On Sun, Jan 27, 2013 at 3:10 AM, jupiter  wrote:
>> Hi,
>>
>> I  have a client.php which calls an external python socket client
>> program exec("Client.py"), the Client.py calls
>> sockobj.connect(("localhost", 6)) to connect socket.
>>
>> If I run the client.php from Linux command line $ ./client.php, it
>> works find, no problem at all.
>>
>> But when I run it from web page http://localhost/client.php, it could
>> not connect to socket at following exception in python
>> sockobj.connect(("localhost", 6)):
>>
>> "sockobj.connect Errno 13 Permission denied"
>>
>> Why it can run from command line, but cannot make socket connection
>> from web? Does it need some kind of configuration in php or apache?
>> Appreciate any tips and clues.
>>
>> Thank you.
>>
>> Kind regards.
>> I am puzzled by
>
> First question: why use a separate program and language to call a
> socket? PHP has two ways of doing it, using the Socket extension and
> using the Stream extension. The Stream extension is a little nicer as
> you just use standard PHP file functions on it.

I knew it was a bad example to run external python, so I tried to run
socket connection directly from the php file client.php, it got the
same error "socket_connect() failed. Reason: () Permission denied" at
$result = socket_connect($socket, "localhost", 6).

Once again, it was fine to run the client.php from the command line. I
can feel something was missing either in php or apache  


> To look here, though, you might want to look at the permissions on
> client.py to make sure it as well as the requisite paths to get to the
> script are readable and executable by the user running your webserver,
> or alternatively, your php scripts if running something like fcgi.

Forget about client.py, and all files are with 755 access permission.
It is not my first time to program and run php, but it is my first
time to run php file calling socket connection. Something was not
quite right here.

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



Re: [PHP] What needs to configure to run php exec for socket connection?

2013-01-27 Thread Ashley Sheridan
On Sun, 2013-01-27 at 03:45 -0600, tamouse mailing lists wrote:

> On Sun, Jan 27, 2013 at 3:10 AM, jupiter  wrote:
> > Hi,
> >
> > I  have a client.php which calls an external python socket client
> > program exec("Client.py"), the Client.py calls
> > sockobj.connect(("localhost", 6)) to connect socket.
> >
> > If I run the client.php from Linux command line $ ./client.php, it
> > works find, no problem at all.
> >
> > But when I run it from web page http://localhost/client.php, it could
> > not connect to socket at following exception in python
> > sockobj.connect(("localhost", 6)):
> >
> > "sockobj.connect Errno 13 Permission denied"
> >
> > Why it can run from command line, but cannot make socket connection
> > from web? Does it need some kind of configuration in php or apache?
> > Appreciate any tips and clues.
> >
> > Thank you.
> >
> > Kind regards.
> > I am puzzled by
> 
> First question: why use a separate program and language to call a
> socket? PHP has two ways of doing it, using the Socket extension and
> using the Stream extension. The Stream extension is a little nicer as
> you just use standard PHP file functions on it.
> 
> To look here, though, you might want to look at the permissions on
> client.py to make sure it as well as the requisite paths to get to the
> script are readable and executable by the user running your webserver,
> or alternatively, your php scripts if running something like fcgi.
> 


I'll take a bet that the Apache server is running as a different user
from your login, and doesn't have permissions to open sockets. You could
either give the Apache user permissions, or put the exec call as part of
an argument of sudo.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] What needs to configure to run php exec for socket connection?

2013-01-27 Thread tamouse mailing lists
On Sun, Jan 27, 2013 at 3:10 AM, jupiter  wrote:
> Hi,
>
> I  have a client.php which calls an external python socket client
> program exec("Client.py"), the Client.py calls
> sockobj.connect(("localhost", 6)) to connect socket.
>
> If I run the client.php from Linux command line $ ./client.php, it
> works find, no problem at all.
>
> But when I run it from web page http://localhost/client.php, it could
> not connect to socket at following exception in python
> sockobj.connect(("localhost", 6)):
>
> "sockobj.connect Errno 13 Permission denied"
>
> Why it can run from command line, but cannot make socket connection
> from web? Does it need some kind of configuration in php or apache?
> Appreciate any tips and clues.
>
> Thank you.
>
> Kind regards.
> I am puzzled by

First question: why use a separate program and language to call a
socket? PHP has two ways of doing it, using the Socket extension and
using the Stream extension. The Stream extension is a little nicer as
you just use standard PHP file functions on it.

To look here, though, you might want to look at the permissions on
client.py to make sure it as well as the requisite paths to get to the
script are readable and executable by the user running your webserver,
or alternatively, your php scripts if running something like fcgi.

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



[PHP] What needs to configure to run php exec for socket connection?

2013-01-27 Thread jupiter
Hi,

I  have a client.php which calls an external python socket client
program exec("Client.py"), the Client.py calls
sockobj.connect(("localhost", 6)) to connect socket.

If I run the client.php from Linux command line $ ./client.php, it
works find, no problem at all.

But when I run it from web page http://localhost/client.php, it could
not connect to socket at following exception in python
sockobj.connect(("localhost", 6)):

"sockobj.connect Errno 13 Permission denied"

Why it can run from command line, but cannot make socket connection
from web? Does it need some kind of configuration in php or apache?
Appreciate any tips and clues.

Thank you.

Kind regards.
I am puzzled by

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



Re: [PHP] exec to launch putty.exe for telnet

2012-07-10 Thread Hans Åhlin
2012/7/3 Devang Patel 

> Hello Experts,
>
> I have putty.exe on my desktop so if I will go to command prompt and then
> to  C:\Documents and Settings\user\Desktop location and execute following
> command it will launch the Putty window of telnet connection to server
> specified:
>
>  putty.exe telnet://10.3.215.15/
>
>
>
> I am trying to launch the putty to telnet to specific server using
> following but its not working for me:
>
>  $securecrt = "C:\\Documents and Settings\\user\\Desktop\\putty.exe
> telnet://
> 10.3.215.15/ ";
>
>
> exec($securecrt);
> ?>
>
> If I try following then it launches the putty application but will have to
> provide the host name or IP to login:
>
>  $securecrt = "C:\\Documents and Settings\\user\\Desktop\\putty.exe ";
>
>
> exec($securecrt);
> ?>
>
> Not sure if I am missing something very basic, It will be great if someone
> can help with this.
>
> Thanks,
> Devang
>

Try Putting an extra " at the beginning and the end of the string. you have
a white space in the exec call and it will chop of the string after it.

$securecrt = "\"C:\\Documents and Settings\\user\\Desktop\\putty.exe
telnet://
10.3.215.15/\"";

-- 


**
 Hans Åhlin
   Tel: +46761488019
   icq: 275232967
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**


Re: [PHP] exec to launch putty.exe for telnet

2012-07-03 Thread Matijn Woudt
On Tue, Jul 3, 2012 at 8:24 PM, Devang Patel  wrote:
> Hello Experts,
>
> I have putty.exe on my desktop so if I will go to command prompt and then
> to  C:\Documents and Settings\user\Desktop location and execute following
> command it will launch the Putty window of telnet connection to server
> specified:
>
>  putty.exe telnet://10.3.215.15/
>
>
>
> I am trying to launch the putty to telnet to specific server using
> following but its not working for me:
>
>  $securecrt = "C:\\Documents and Settings\\user\\Desktop\\putty.exe telnet://
> 10.3.215.15/ ";
>
>
> exec($securecrt);
> ?>
>
> If I try following then it launches the putty application but will have to
> provide the host name or IP to login:
>
>  $securecrt = "C:\\Documents and Settings\\user\\Desktop\\putty.exe ";
>
>
> exec($securecrt);
> ?>
>
> Not sure if I am missing something very basic, It will be great if someone
> can help with this.
>
> Thanks,
> Devang

Hi Devang,

What version of PHP are you using? It seems there is a bug with PHP
version 5.2 and lower on windows which requires you to add extra
quotes to the input, though, doing so will result in errors on PHP
version 5.3 and up.
Also, are you getting any specific errors? Maybe you can explain a
little more detailed of what isn't working exactly?

- Matijn

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



[PHP] exec to launch putty.exe for telnet

2012-07-03 Thread Devang Patel
Hello Experts,

I have putty.exe on my desktop so if I will go to command prompt and then
to  C:\Documents and Settings\user\Desktop location and execute following
command it will launch the Putty window of telnet connection to server
specified:

 putty.exe telnet://10.3.215.15/



I am trying to launch the putty to telnet to specific server using
following but its not working for me:



If I try following then it launches the putty application but will have to
provide the host name or IP to login:



Not sure if I am missing something very basic, It will be great if someone
can help with this.

Thanks,
Devang


Re: [PHP] Exec Script in the background, don't wait till it finishes

2011-01-14 Thread Richard Quadling
On 14 January 2011 18:48, Nicholas Kell  wrote:
>
> On Jan 14, 2011, at 12:41 PM, Kai Renz wrote:
>
>> Hi guys and thanks for your answers...
>>
>> @Nicholas:
>> Yes, you are right. The first socket is only used if a new clients
>> connects, thats why the script generates a new port so the client can
>> connect to the new socket. After that socket1 should continue its work
>> and wait for new clients.
>>
>> @Daniel:
>> Yeh i tried sending it to the background, this works but still it does
>> wait for the other script to finish.
>>
>> @Evil Son:
>> Thanks for the tip, i'll try it :)
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
> One more thing to verify: What is the target environment? *nix I hope.

You can launch a non-blocking process in Windows using PHP. I do this a lot.

Run('C:\\PHP5\\php-win.exe -f script.php --
script_params_would_go_here', 0, False);
// This script can now continue and script.php will be running in parallel.
?>

I use WinCache's Ucache to pass data between the multiple "threads".

Now, use the PECL extension Win32Service, and you can use PHP for
Windows Services, multi-threaded with inter-thread communication.

If you feel mad enough.

Regards,

Richard.

[1] http://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.85).aspx


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] Exec Script in the background, don't wait till it finishes

2011-01-14 Thread Nicholas Kell

On Jan 14, 2011, at 12:41 PM, Kai Renz wrote:

> Hi guys and thanks for your answers...
> 
> @Nicholas:
> Yes, you are right. The first socket is only used if a new clients
> connects, thats why the script generates a new port so the client can
> connect to the new socket. After that socket1 should continue its work
> and wait for new clients.
> 
> @Daniel:
> Yeh i tried sending it to the background, this works but still it does
> wait for the other script to finish.
> 
> @Evil Son:
> Thanks for the tip, i'll try it :)
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


Your not going to be able to push it to the background, it will always wait no 
matter where you push it.

You will have to spawn another full script. The pcntl_fork() function is what 
you are looking for, but it works a tad less than optimal in this situation.


Here is a QnD of a class and using it. This thing creates a bit of a mess, but 
it illustrates that the parent doesn't wait on the child to die.
You will need to write some logic to determine if it is the parent or child 
fork that is running, and also keep track of your ports.

Like I said earlier, it creates a mess, but clearly illustrates pcntl_fork(); 
This is a messy thing to be implementing in PHP.

open();
$_socket->handleNewClient(++$_port);
$_socket->handleNewClient(++$_port);
$_socket->handleNewClient(++$_port);
$_socket->handleNewClient(++$_port);
$_socket->handleNewClient(++$_port);

echo "\n~~ End $_pid\t";

class MySocket {

private $port;

public function __construct($_port) {
$this->port = getmypid(); //Use port number if ya want - I used PID for 
uniqueness
echo "\n--- Created new port $this->port\t";
}

public function open() {
echo "\nOpen port: $this->port\n";
for ($_i = 0; $_i < 100; $_i++) {// Do some thinking: Clog up the buffer
echo "[$this->port]";
}

}

public function close() {
echo "\n=== Closing $this->port\t";
}

public function handleNewClient($_port) {
$_socket = new MySocket($_port);
$_socket->open();
pcntl_fork(); // Creates an exponential mess
$_socket->close(); // Close socket after spawning another script
}

// Rest of class logic...
}
?>

Re: [PHP] Exec Script in the background, don't wait till it finishes

2011-01-14 Thread Nicholas Kell

On Jan 14, 2011, at 12:41 PM, Kai Renz wrote:

> Hi guys and thanks for your answers...
> 
> @Nicholas:
> Yes, you are right. The first socket is only used if a new clients
> connects, thats why the script generates a new port so the client can
> connect to the new socket. After that socket1 should continue its work
> and wait for new clients.
> 
> @Daniel:
> Yeh i tried sending it to the background, this works but still it does
> wait for the other script to finish.
> 
> @Evil Son:
> Thanks for the tip, i'll try it :)
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


One more thing to verify: What is the target environment? *nix I hope.

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



Re: [PHP] Exec Script in the background, don't wait till it finishes

2011-01-14 Thread Kai Renz
Hi guys and thanks for your answers...

@Nicholas:
Yes, you are right. The first socket is only used if a new clients
connects, thats why the script generates a new port so the client can
connect to the new socket. After that socket1 should continue its work
and wait for new clients.

@Daniel:
Yeh i tried sending it to the background, this works but still it does
wait for the other script to finish.

@Evil Son:
Thanks for the tip, i'll try it :)

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



Re: [PHP] Exec Script in the background, don't wait till it finishes

2011-01-14 Thread Daniel Brown
On Fri, Jan 14, 2011 at 13:28, Kai Renz  wrote:

(Putting this back on the list.  Please use Reply-All.)

> @Daniel:
> Yeh i tried sending it to the background, this works but still it does
> wait for the other script to finish.

It shouldn't.  In fact, just to see if I somehow completely forgot
how things worked, I just mocked up the following and verified it
worked perfectly:

> /dev/null 2>&1 &`;

echo 'I will now terminate, while the other script continues.'.PHP_EOL;
?>



dan@blackbox:~$ php 1.php
I will now terminate, while the other script continues.
dan@blackbox:~$ tail -f ./123-whee.txt
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
^C
dan@blackbox:~$ ps -ef | grep -i php
dan  29428 1 34 13:37 pts/166  00:00:24 php ./2.php
dan  29491 28729  0 13:38 pts/166  00:00:00 grep --color=auto -i php

-- 

Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



Fwd: [PHP] Exec Script in the background, don't wait till it finishes

2011-01-14 Thread Evil Son
Sorry, not sent to the list.


-- Forwarded message --
From: Evil Son 
Date: Sat, Jan 15, 2011 at 4:26 AM
Subject: Re: [PHP] Exec Script in the background, don't wait till it finishes
To: Kai Renz 


On Sat, Jan 15, 2011 at 2:56 AM, Kai Renz  wrote:
> Hi there,
>
> i'm currently working on a socket project. It consists of two scripts.
> The first script (socket1.php) creates a socket on a specified port
> and waits for a client to connect. If a client connects, they exchange
> some informations, including a random created port. Next, the first
> script calls the second script (socket2.php) with the just created
> port number as a parameter.
>
> Now here is the problem:
> it all works fine, but the client can't send a quit message to socket1
> because socket1.php waits until socket2.php is finished. socket2.php
> is working properly, and if i connect to the new socket and quit the
> connection, socket1 is working again. All i need socket1 to do is to
> continue working independant of socket2.
>
> I tried everything, from shell_exec to pcntl_exec, nothing seems to work.

Looking at the manual, shell_exec will wait for the other script to
return (just like calling the 2nd script"), pcntl_exec replaces the
original server with the new one. pcntl_fork is what you want but it
is non-windows. Hopefully you are running on *nix.

HTH

--
Regards
Evil Son



-- 
Regards
Evil Son

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



Re: [PHP] Exec Script in the background, don't wait till it finishes

2011-01-14 Thread Daniel Brown
On Fri, Jan 14, 2011 at 11:56, Kai Renz  wrote:
>
> Now here is the problem:
> it all works fine, but the client can't send a quit message to socket1
> because socket1.php waits until socket2.php is finished. socket2.php
> is working properly, and if i connect to the new socket and quit the
> connection, socket1 is working again. All i need socket1 to do is to
> continue working independant of socket2.
>
> I tried everything, from shell_exec to pcntl_exec, nothing seems to work.

Have you looked into pcntl_fork() or running it in the background
via something as simple as backticks?  The latter of which,
exemplified:

> /path/to/log.txt 2>&1 &`;
?>

Expanding on that, you could do something like this:

>
/path/to/log.txt 2>&1 &',$ret,$err);

if ($err === 0) {

exec('echo $$',$ret);
$pid = $response[0];
echo $pid.PHP_EOL;

} else {

echo 'There was an error while forking the process.  Please
view the log.'.PHP_EOL;

}
?>

-- 

Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



Re: [PHP] Exec Script in the background, don't wait till it finishes

2011-01-14 Thread Nicholas Kell

On Jan 14, 2011, at 10:56 AM, Kai Renz wrote:

> Hi there,
> 
> i'm currently working on a socket project. It consists of two scripts.
> The first script (socket1.php) creates a socket on a specified port
> and waits for a client to connect. If a client connects, they exchange
> some informations, including a random created port. Next, the first
> script calls the second script (socket2.php) with the just created
> port number as a parameter.
> 
> Now here is the problem:
> it all works fine, but the client can't send a quit message to socket1
> because socket1.php waits until socket2.php is finished. socket2.php
> is working properly, and if i connect to the new socket and quit the
> connection, socket1 is working again. All i need socket1 to do is to
> continue working independant of socket2.
> 
> I tried everything, from shell_exec to pcntl_exec, nothing seems to work.
> 
> regards,
> Kai
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


To the best of my knowledge you are kind of in a hard place with that type of 
situation. 

I hate to be the guy that in the last three weeks mentions using a different 
language for an issue, but I honestly think that you may have a higher return 
using a language that supports threads a bit better. Hope this doesn't start 
another language battle.

Don't get me wrong, I love PHP, but there are certain things that a different 
tool may be easier to solve the problem with.


PHP or not: Could you describe the issue a bit more? What is the goal, at the 
end of the day?

Here is what I am gathering:

Open a socket 
client connects
get client to a different port to run independently


Can I assume that the goal of moving them to a different port is to be able to 
accept more clients on the first port?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Exec Script in the background, don't wait till it finishes

2011-01-14 Thread Kai Renz
Hi there,

i'm currently working on a socket project. It consists of two scripts.
The first script (socket1.php) creates a socket on a specified port
and waits for a client to connect. If a client connects, they exchange
some informations, including a random created port. Next, the first
script calls the second script (socket2.php) with the just created
port number as a parameter.

Now here is the problem:
it all works fine, but the client can't send a quit message to socket1
because socket1.php waits until socket2.php is finished. socket2.php
is working properly, and if i connect to the new socket and quit the
connection, socket1 is working again. All i need socket1 to do is to
continue working independant of socket2.

I tried everything, from shell_exec to pcntl_exec, nothing seems to work.

regards,
Kai

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



Re: [PHP] exec output to mySQL, How?

2010-07-21 Thread Per Jessen
Nilesh Govindarajan wrote:

> On Wed, Jul 21, 2010 at 12:29 PM, Per Jessen  wrote:
>> Tom Sparks wrote:
>>
>>> How do I take the output from a command line program and update a
>>> MYSQL database with it?
>>
>>  | mysql -u user -p -Ddatabase
>>
> 
> I don't think this is what he needs? Otherwise why would he post on a
> PHP list lol.

Who knows, but I answered his question.  Besides, he doesn't need PHP to
do mysql updates with output from a command line program. 



-- 
Per Jessen, Zürich (23.3°C)


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



Re: [PHP] exec output to mySQL, How?

2010-07-21 Thread Ashley Sheridan
On Wed, 2010-07-21 at 12:57 +0530, Nilesh Govindarajan wrote:

> On Wed, Jul 21, 2010 at 12:29 PM, Per Jessen  wrote:
> > Tom Sparks wrote:
> >
> >> How do I take the output from a command line program and update a
> >> MYSQL database with it?
> >
> >  | mysql -u user -p -Ddatabase
> >
> >
> >
> > --
> > Per Jessen, Zürich (22.6°C)
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> I don't think this is what he needs? Otherwise why would he post on a
> PHP list lol.
> 
> -- 
> Regards,
> Nilesh Govindarajan
> Facebook: http://www.facebook.com/nilesh.gr
> Twitter: http://twitter.com/nileshgr
> Website: http://www.itech7.com
> 


Because many people wouldn't know that Linux can happily deal with this
on the command line, so would assume they would have to use a scripting
language to perform the task.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] exec output to mySQL, How?

2010-07-21 Thread Nilesh Govindarajan
On Wed, Jul 21, 2010 at 12:39 PM, Tom Sparks  wrote:
> --- On Wed, 21/7/10, Nilesh Govindarajan  wrote:
>> On Wed, Jul 21, 2010 at 8:49 AM, Tom
>> Sparks 
>> wrote:
>> > How do I take the output from a command line program
>> and update a MYSQL database with it?
>> >
>> > tom_a_sparks
>> > Light travels faster then sound, which is why some
>> people appear bright, until you hear them speak
>> >
>>
>> $cmdop=shell_exec('cmd');
>> $con=new mysqli(...);
>> // Check connection error
>> // Refer to php.net/mysqli
>> $con->multi_query($cmdop);
> ok, thanks the program I am using reports a estimated time to completion, I 
> understand I need a loop, but I cant work out how I would do this
>
> run program
> while program is running {
> sleep 60 seconds
> update mySQL with ET from program
> }
>
> tom
>
>
>
>

You want to calculate how much time the query takes?

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com

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



Re: [PHP] exec output to mySQL, How?

2010-07-21 Thread Nilesh Govindarajan
On Wed, Jul 21, 2010 at 12:29 PM, Per Jessen  wrote:
> Tom Sparks wrote:
>
>> How do I take the output from a command line program and update a
>> MYSQL database with it?
>
>  | mysql -u user -p -Ddatabase
>
>
>
> --
> Per Jessen, Zürich (22.6°C)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I don't think this is what he needs? Otherwise why would he post on a
PHP list lol.

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com

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



Re: [PHP] exec output to mySQL, How?

2010-07-21 Thread Tom Sparks
--- On Wed, 21/7/10, Nilesh Govindarajan  wrote:
> On Wed, Jul 21, 2010 at 8:49 AM, Tom
> Sparks 
> wrote:
> > How do I take the output from a command line program
> and update a MYSQL database with it?
> >
> > tom_a_sparks
> > Light travels faster then sound, which is why some
> people appear bright, until you hear them speak
> >
> 
> $cmdop=shell_exec('cmd');
> $con=new mysqli(...);
> // Check connection error
> // Refer to php.net/mysqli
> $con->multi_query($cmdop);
ok, thanks the program I am using reports a estimated time to completion, I 
understand I need a loop, but I cant work out how I would do this

run program
while program is running {
sleep 60 seconds
update mySQL with ET from program
}

tom


  

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



Re: [PHP] exec output to mySQL, How?

2010-07-21 Thread Per Jessen
Tom Sparks wrote:

> How do I take the output from a command line program and update a
> MYSQL database with it?

 | mysql -u user -p -Ddatabase



-- 
Per Jessen, Zürich (22.6°C)


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



Re: [PHP] exec output to mySQL, How?

2010-07-20 Thread Nilesh Govindarajan
On Wed, Jul 21, 2010 at 8:49 AM, Tom Sparks  wrote:
> How do I take the output from a command line program and update a MYSQL 
> database with it?
>
> tom_a_sparks
> Light travels faster then sound, which is why some people appear bright, 
> until you hear them speak
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

$cmdop=shell_exec('cmd');
$con=new mysqli(...);
// Check connection error
// Refer to php.net/mysqli
$con->multi_query($cmdop);

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com

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



[PHP] exec output to mySQL, How?

2010-07-20 Thread Tom Sparks
How do I take the output from a command line program and update a MYSQL 
database with it?

tom_a_sparks
Light travels faster then sound, which is why some people appear bright, until 
you hear them speak




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



[PHP] Exec not functioning

2010-06-30 Thread kronos

Hi,

I'm trying to utilize EXEC to have some text from a db query converted to  
a wav file using 'espeak'.
The 'espeak' command works admirably by cli, but no matter what I do, exec  
does not

seem to function on my Linux box, even though safe_mode is off.

I've stripped the db query out, and ran a simplified text, 'Hallo Toofie'  
in the code. First off,

I made sure that the espeak code worked by cli. It does.

The code:

	$command = "/usr/bin/espeak -g0 -ven+m3 -p22 -s170 'Hallo Toofie' -w  
aba.wav";


exec($command);

?>


I've tried every combination I can think of including using 'espeak'  
without '/usr/bin',

directing wav output to '-f /home/kronos/aba.wav'.

What am I doing wrong?

Any help, pointers, suggestions appreciated!


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



Re: [PHP] exec in different directory where PHP is Installed

2010-05-25 Thread loki

I have a begin of explanation

When PHP is run as CGI it's work but with this header message :

'\\xxx.xxx.xxx.xxx\scriptdir'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
Status: 200 OK
X-Powered-By: PHP/5.2.8
Content-type: text/html

@exec function work well


Now when PHP is run as a FAST-CGI then it's not work at
ALL (ie: just the @exec function not work, the other work ok!)


is it a normal behavior ?

thanks you by advance
stephane



On 5/24/2010 11:42 PM, Bob McConnell wrote:

From: loki


On 5/24/2010 11:31 PM, Bob McConnell wrote:

From: loki


PHP is installed in c:\program files\php
the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
in the PHP script, we try to launch the command @exec(...) with a
executable located in c:\program files\ourexecutable\

it's not work :(

but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
to c:\scriptdir\ then it's work !!

everything work good EXCEPT the @EXEC command ...


Is 'C:\Program Files\PHP' in your PATH? You may need to add that
manually.


no ? but why i would need to add C:\Program Files\PHP in my path ?
why it's explain that it's work when the php script are located in any



directory under c: and not under \\xxx.xxx.xxx.xxx\scriptdir\ ??


What is the exact error message you get when it doesn't work?

Bob McConnell



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



Re: [PHP] exec in different directory where PHP is Installed

2010-05-24 Thread Kevin Kinsey

loki wrote:

Hello,

PHP is installed in c:\program files\php
the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
in the PHP script, we try to launch the command @exec(...) with a 
executable located in c:\program files\ourexecutable\

it's not work :(

but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
to c:\scriptdir\ then it's work !!

everything work good EXCEPT the @EXEC command ...
Safe mode in PHP is OFF ...


Hello,

   Can you show us the script?  The first thing I'd do is
call "is_file(\\xxx.xxx.xxx.xxx\scriptdir\foo.php)" ... are
you doing that?

Kevin Kinsey

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



RE: [PHP] exec in different directory where PHP is Installed

2010-05-24 Thread Bob McConnell
From: loki

> On 5/24/2010 11:31 PM, Bob McConnell wrote:
>> From: loki
>>
>>> PHP is installed in c:\program files\php
>>> the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
>>> in the PHP script, we try to launch the command @exec(...) with a
>>> executable located in c:\program files\ourexecutable\
>>>
>>> it's not work :(
>>>
>>> but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
>>> to c:\scriptdir\ then it's work !!
>>>
>>> everything work good EXCEPT the @EXEC command ...
>>
>> Is 'C:\Program Files\PHP' in your PATH? You may need to add that
>> manually.
> 
> no ? but why i would need to add C:\Program Files\PHP in my path ?
> why it's explain that it's work when the php script are located in any

> directory under c: and not under \\xxx.xxx.xxx.xxx\scriptdir\ ??

What is the exact error message you get when it doesn't work?

Bob McConnell

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



Re: [PHP] exec in different directory where PHP is Installed

2010-05-24 Thread loki

On 5/24/2010 11:31 PM, Bob McConnell wrote:

From: loki


PHP is installed in c:\program files\php
the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
in the PHP script, we try to launch the command @exec(...) with a
executable located in c:\program files\ourexecutable\

it's not work :(

but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
to c:\scriptdir\ then it's work !!

everything work good EXCEPT the @EXEC command ...


Is 'C:\Program Files\PHP' in your PATH? You may need to add that
manually.

Bob McConnell


no ? but why i would need to add C:\Program Files\PHP in my path ?
why it's explain that it's work when the php script are located in any 
directory under c: and not under \\xxx.xxx.xxx.xxx\scriptdir\ ??


thanks by advance
stephane


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



Re: [PHP] exec in different directory where PHP is Installed

2010-05-24 Thread loki

the script is vbulletin


	function fetch_im_exec($command, $args, $needoutput = false, $dieongs = 
true)

{
if (!function_exists('exec'))
{
$this->error = 
array(fetch_error('php_error_exec_disabled'));
return false;
}

$imcommands = array(
'identify' => $this->identifypath,
'convert'  => $this->convertpath,
);

$input = $imcommands["$command"] . ' ' . $args . ' 2>&1';
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' AND PHP_VERSION < 
'5.3.0')
{
$input = '"' . $input . '"';
}
$exec = @exec($input, $output, $this->returnvalue);


when i put the script in \\xxx.xxx.xxx.xxx\scriptdir\
the result is empty
when i put the script everywhere in the c: then
the result is good !

in both case $input is the same and point to c:\program 
files\im\identify.exe


i use php 5.2.8 on windows

thanks by advance
stephane





On 5/24/2010 11:11 PM, Kevin Kinsey wrote:

loki wrote:

Hello,

PHP is installed in c:\program files\php
the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
in the PHP script, we try to launch the command @exec(...) with a
executable located in c:\program files\ourexecutable\
it's not work :(

but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
to c:\scriptdir\ then it's work !!

everything work good EXCEPT the @EXEC command ...
Safe mode in PHP is OFF ...


Hello,

Can you show us the script? The first thing I'd do is
call "is_file(\\xxx.xxx.xxx.xxx\scriptdir\foo.php)" ... are
you doing that?

Kevin Kinsey



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



RE: [PHP] exec in different directory where PHP is Installed

2010-05-24 Thread Bob McConnell
From: loki

> PHP is installed in c:\program files\php
> the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
> in the PHP script, we try to launch the command @exec(...) with a 
> executable located in c:\program files\ourexecutable\
> 
> it's not work :(
> 
> but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
> to c:\scriptdir\ then it's work !!
> 
> everything work good EXCEPT the @EXEC command ...

Is 'C:\Program Files\PHP' in your PATH? You may need to add that
manually.

Bob McConnell

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



[PHP] exec in different directory where PHP is Installed

2010-05-24 Thread loki

Hello,

PHP is installed in c:\program files\php
the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
in the PHP script, we try to launch the command @exec(...) with a 
executable located in c:\program files\ourexecutable\


it's not work :(

but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
to c:\scriptdir\ then it's work !!

everything work good EXCEPT the @EXEC command ...

Safe mode in PHP is OFF ...

Thanks by advance for you help
stephane

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



Re: [PHP] exec() problem [SOLVED]

2009-11-14 Thread A. Mannini

Ashley Sheridan ha scritto:

On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:


Ashley Sheridan ha scritto:
Have you checked to ensure that the exec is actually running at all? 
Check the error logs to see what they say. There may be a problem with 
the string argument for exec(), like an unescaped character that is 
causing an issue


Thanks,
Ash
http://www.ashleysheridan.co.uk


Yes i had no messages in Apache logs so i tried to use error_log in 
php.ini but again no messages.
Don't know if there is a way to see what php module interpeter and try 
to execute.


Thanks

Alessandro




I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk





Ok commenting out Defaults requiretty now it works!

The second message "
sudo: no tty present and no askpass program specified" was due to wrong 
command issued during tests.


Many thanks

Alessandro

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



Re: [PHP] exec() problem

2009-11-14 Thread A. Mannini

Ashley Sheridan ha scritto:

On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:


Ashley Sheridan ha scritto:
Have you checked to ensure that the exec is actually running at all? 
Check the error logs to see what they say. There may be a problem with 
the string argument for exec(), like an unescaped character that is 
causing an issue


Thanks,
Ash
http://www.ashleysheridan.co.uk


Yes i had no messages in Apache logs so i tried to use error_log in 
php.ini but again no messages.
Don't know if there is a way to see what php module interpeter and try 
to execute.


Thanks

Alessandro




I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk





Ok i found that Fedora has, as default, a line Defaults requiretty in 
/etc/sudoers, i disabled that but i get a different message.


sudo: no tty present and no askpass program specified


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



Re: [PHP] exec() problem

2009-11-14 Thread Kim Madsen

Ashley Sheridan wrote on 2009-11-15 00:23:


Looked to all log...nothing! :-(




What other logs did you look at?


Then do this from a command line:

su - "the user apache runs as"

copy the command from the ph script and run it from commandline and let 
us see the error you recieve...


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] exec() problem

2009-11-14 Thread Ashley Sheridan
On Sun, 2009-11-15 at 00:25 +0100, A. Mannini wrote:

> Ashley Sheridan ha scritto:
> > On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:
> > 
> >> Ashley Sheridan ha scritto:
> >>> Have you checked to ensure that the exec is actually running at all? 
> >>> Check the error logs to see what they say. There may be a problem with 
> >>> the string argument for exec(), like an unescaped character that is 
> >>> causing an issue
> >>>
> >>> Thanks,
> >>> Ash
> >>> http://www.ashleysheridan.co.uk
> >>>
> >>>
> >> Yes i had no messages in Apache logs so i tried to use error_log in 
> >> php.ini but again no messages.
> >> Don't know if there is a way to see what php module interpeter and try 
> >> to execute.
> >>
> >> Thanks
> >>
> >> Alessandro
> >>
> > 
> > 
> > I think for something like that, you should be looking at your system
> > logs, as that's likely where the errors would log.
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> > 
> 
> Looked to all log...nothing! :-(
> 


What other logs did you look at?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] exec() problem

2009-11-14 Thread A. Mannini

Ashley Sheridan ha scritto:

On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:


Ashley Sheridan ha scritto:
Have you checked to ensure that the exec is actually running at all? 
Check the error logs to see what they say. There may be a problem with 
the string argument for exec(), like an unescaped character that is 
causing an issue


Thanks,
Ash
http://www.ashleysheridan.co.uk


Yes i had no messages in Apache logs so i tried to use error_log in 
php.ini but again no messages.
Don't know if there is a way to see what php module interpeter and try 
to execute.


Thanks

Alessandro




I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk





Looked to all log...nothing! :-(

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



Re: [PHP] exec() problem

2009-11-14 Thread Ashley Sheridan
On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:

> Ashley Sheridan ha scritto:
> >
> > Have you checked to ensure that the exec is actually running at all? 
> > Check the error logs to see what they say. There may be a problem with 
> > the string argument for exec(), like an unescaped character that is 
> > causing an issue
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> 
> Yes i had no messages in Apache logs so i tried to use error_log in 
> php.ini but again no messages.
> Don't know if there is a way to see what php module interpeter and try 
> to execute.
> 
> Thanks
> 
> Alessandro
> 


I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] exec() problem

2009-11-14 Thread A. Mannini

Ashley Sheridan ha scritto:


Have you checked to ensure that the exec is actually running at all? 
Check the error logs to see what they say. There may be a problem with 
the string argument for exec(), like an unescaped character that is 
causing an issue


Thanks,
Ash
http://www.ashleysheridan.co.uk




Yes i had no messages in Apache logs so i tried to use error_log in 
php.ini but again no messages.
Don't know if there is a way to see what php module interpeter and try 
to execute.


Thanks

Alessandro

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



[PHP] exec() problem

2009-11-14 Thread A. Mannini

 Hi all,

i've a problem using exec() on a Linux server with PHP 5.2.9 on Apache
2.2.13. Safe mode is OFF and Apache isn't chrooted.

I would run /usr/lib/mailman/bin/find_member -l   so i used
exec("sudo run /usr/lib/mailman/bin/find_member -l 
",$output) and set /etc/sudoers with apache ALL=NOPASSWD:
/usr/lib/mailman/bin/find_memberbut it doesn't work.

I tried simple commands "/bin/ls" works, "sudo -V" work but "sudo
/bin/ls" doesn't work.

I get return code 1 and no messages in logs..

What is worng?

Thanks

Alessandro

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



Re: [PHP] exec() problem

2009-11-14 Thread Ashley Sheridan
On Sat, 2009-11-14 at 22:20 +0100, A. Mannini wrote:

> Hi all,
> 
> i've a problem using exec() on a Linux server with PHP 5.2.9 on Apache 
> 2.2.13. Safe mode is OFF and Apache isn't chrooted.
> 
> I would run /usr/lib/mailman/bin/find_member -l   so i used 
> exec("sudo run /usr/lib/mailman/bin/find_member -l  
> ",$output) and set /etc/sudoers with apache ALL=NOPASSWD: 
> /usr/lib/mailman/bin/find_memberbut it doesn't work.
> 
> I tried simple commands "/bin/ls" works, "sudo -V" work but "sudo 
> /bin/ls" doesn't work.
> 
> I get return code 1 and no messages in logs..
> 
> What is worng?
> 
> Thanks
> 
> Alessandro
> 


Did you mean to put 'run' into the exec call?

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] exec() problem

2009-11-14 Thread A. Mannini

 Hi all,

i've a problem using exec() on a Linux server with PHP 5.2.9 on Apache 
2.2.13. Safe mode is OFF and Apache isn't chrooted.


I would run /usr/lib/mailman/bin/find_member -l   so i used 
exec("sudo run /usr/lib/mailman/bin/find_member -l  
",$output) and set /etc/sudoers with apache ALL=NOPASSWD: 
/usr/lib/mailman/bin/find_memberbut it doesn't work.


I tried simple commands "/bin/ls" works, "sudo -V" work but "sudo 
/bin/ls" doesn't work.


I get return code 1 and no messages in logs..

What is worng?

Thanks

Alessandro

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



Re: [PHP] exec() confused by a specially crafted string

2009-10-12 Thread Eddie Drapkin
On Mon, Oct 12, 2009 at 2:10 PM, Soner Tari  wrote:
> On Mon, 2009-10-12 at 13:21 -0300, Jonathan Tapicer wrote:
>> Confirmed, it also happens to me on Linux, PHP version:
>>
>> PHP 5.2.4-2ubuntu5.7 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21
>> 2009 19:52:39)
>> Copyright (c) 1997-2007 The PHP Group
>> Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
>>
>> And adding a single character to the echoed string makes it work fine,
>> seems like a bug to me.
>
> Thanks, filed the bug report:
> http://bugs.php.net/bug.php?id=49847
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Confirmed (again) here:

PHP Version => 5.3.0
Build Date => Jul  1 2009 17:55:55

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



Re: [PHP] exec() confused by a specially crafted string

2009-10-12 Thread Soner Tari
On Mon, 2009-10-12 at 13:21 -0300, Jonathan Tapicer wrote:
> Confirmed, it also happens to me on Linux, PHP version:
> 
> PHP 5.2.4-2ubuntu5.7 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21
> 2009 19:52:39)
> Copyright (c) 1997-2007 The PHP Group
> Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
> 
> And adding a single character to the echoed string makes it work fine,
> seems like a bug to me.

Thanks, filed the bug report:
http://bugs.php.net/bug.php?id=49847


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



Re: [PHP] exec() confused by a specially crafted string

2009-10-12 Thread Jonathan Tapicer
Confirmed, it also happens to me on Linux, PHP version:

PHP 5.2.4-2ubuntu5.7 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21
2009 19:52:39)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

And adding a single character to the echoed string makes it work fine,
seems like a bug to me.

Regards,

Jonathan

On Mon, Oct 12, 2009 at 1:10 PM, Soner Tari  wrote:
> When shell command returns a specially crafted string, I get an empty
> array as $output of exec(), instead of the string. I can very easily
> reproduce this issue as follows:
>
> Put the following lines in bug.php:
>
>  exec('php echostr.php', $output);
> print_r($output);
> echo "\n";
> ?>
>
> Then put the following in echostr.php (the string is just one line
> actually, new lines may be inserted by this mail agent, I provide a link
> below):
>
>  echo 'a:25:{i:0;a:4:{s:4:"Date";s:6:"Aug
> 7";s:4:"Time";s:8:"16:00:01";s:7:"Process";s:16:"newsyslog[23117]";s:3:"Log";s:19:"logfile
>  turned over";}i:1;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:12:"openvpn[226]";s:3:"Log";s:76:"OpenVPN
>  2.1_rc18 x86_64-unknown-openbsd4.5 [SSL] [LZO1] built on Jun 26 
> 2009";}i:2;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:12:"openvpn[226]";s:3:"Log";s:102:"NOTE:
>  OpenVPN 2.1 requires \'--script-security 2\' or higher to call user-defined 
> scripts or executables";}i:3;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:12:"openvpn[226]";s:3:"Log";s:27:"LZO
>  compression initialized";}i:4;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:12:"openvpn[226]";s:3:"Log";s:63:"Control
>  Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 
> ]";}i:5;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:12:"openvpn[226]";s:3:"Log";s:70:"Data
>  Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 
> ]";}i:6;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:12:"openvpn[226]";s:3:"Log";s:39:"Local
>  Options hash (VER=V4): \'41690919\'";}i:7;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:12:"openvpn[226]";s:3:"Log";s:49:"Expected
>  Remote Options hash (VER=V4): \'530fdded\'";}i:8;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:48:"Socket
>  Buffers: R=[41600->65536] S=[9216->65536]";}i:9;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:25:"UDPv4
>  link local: [undef]";}i:10;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:38:"UDPv4
>  link remote: 81.215.105.114:1194";}i:11;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:98:"TLS
>  Error: TLS key negotiation failed to occur within 60 seconds (check your 
> network connectivity)";}i:12;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:31:"TLS
>  Error: TLS handshake failed";}i:13;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:23:"TCP/UDP:
>  Closing socket";}i:14;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:52:"SIGUSR1[soft,tls-error]
>  received, process restarting";}i:15;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:26:"Restart
>  pause, 2 second(s)";}i:16;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:102:"NOTE:
>  OpenVPN 2.1 requires \'--script-security 2\' or higher to call user-defined 
> scripts or executables";}i:17;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:24:"Re-using
>  SSL/TLS context";}i:18;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:27:"LZO
>  compression initialized";}i:19;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:63:"Control
>  Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 
> ]";}i:20;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:70:"Data
>  Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 
> ]";}i:21;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:39:"Local
>  Options hash (VER=V4): \'41690919\'";}i:22;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:49:"Expected
>  Remote Options hash (VER=V4): \'530fdded\'";}i:23;a:4:{s:4:"Date";s:6:"Aug 
> 10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:48:"Socket
>  Buffers: R=[41600->65536] S=[9216->6553

[PHP] exec() confused by a specially crafted string

2009-10-12 Thread Soner Tari
When shell command returns a specially crafted string, I get an empty
array as $output of exec(), instead of the string. I can very easily
reproduce this issue as follows:

Put the following lines in bug.php:



Then put the following in echostr.php (the string is just one line
actually, new lines may be inserted by this mail agent, I provide a link
below):

65536] S=[9216->65536]";}i:9;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:25:"UDPv4
 link local: [undef]";}i:10;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:43:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:38:"UDPv4
 link remote: 81.215.105.114:1194";}i:11;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:98:"TLS
 Error: TLS key negotiation failed to occur within 60 seconds (check your 
network connectivity)";}i:12;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:31:"TLS
 Error: TLS handshake failed";}i:13;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:23:"TCP/UDP:
 Closing socket";}i:14;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:52:"SIGUSR1[soft,tls-error]
 received, process restarting";}i:15;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:55";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:26:"Restart
 pause, 2 second(s)";}i:16;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:102:"NOTE:
 OpenVPN 2.1 requires \'--script-security 2\' or higher to call user-defined 
scripts or executables";}i:17;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:24:"Re-using
 SSL/TLS context";}i:18;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:27:"LZO
 compression initialized";}i:19;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:63:"Control
 Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 
]";}i:20;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:70:"Data
 Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 
]";}i:21;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:39:"Local
 Options hash (VER=V4): \'41690919\'";}i:22;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:49:"Expected
 Remote Options hash (VER=V4): \'530fdded\'";}i:23;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:48:"Socket
 Buffers: R=[41600->65536] S=[9216->65536]";}i:24;a:4:{s:4:"Date";s:6:"Aug 
10";s:4:"Time";s:8:"22:44:57";s:7:"Process";s:14:"openvpn[31938]";s:3:"Log";s:25:"UDPv4
 link local: [undef]";}}';
?>

When you execute bug.php, you will get an empty array printed out:

Array
(
)

But actually, $output should have contained the string above as element
0 of the array.

If you delete or add a character in the string, exec() runs
correctly and you get the intended result. So the issue is specific to
this special string. You can download echostr.php contents at this link:
http://comixwall.org/dmdocuments/echostr

The problem is not with the size of the string, because much longer
strings are fine.

Also this issue does *not* exists with passthru(), shell_exec()
functions and backtick operator. Furthermore, exec() return value, i.e.
the last line of shell command output seems fine too (it contains the
string correctly). So I believe the issue is internal to exec(),
effecting $output contents only.

As you can guess, this string is in fact serialized openvpn startup log
lines (I just escaped the single quotes for testing purposes, that's
all), it is not some manually crafted string. Therefore, the chances are
quite high that I will get more than one similar situation in the
future, specifically every time the openvpn logs are rotated, and I
start openvpn.

I have confirmed this issue on OpenBSD, Linux, and Windows. Here are the
versions:

OpenBSD:
PHP 5.2.8 with Suhosin-Patch 0.9.6.3 (cli) (built: Mar  1 2009
10:26:06) 
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH

Linux:
PHP 5.2.6-3ubuntu4.2 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21
2009 21:43:13) 
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

Windows:
PHP 5.2.11 (cli) (built: Sep 16 2009 19:39:46)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Since Windows version is without Suhosin patch, suhosin as culprit is
ruled out. (Also to test on Windows, I changed the exec she

Re: [PHP] EXEC and SYSTEM delay

2009-07-23 Thread Sam Stelfox
Well if the server your running on is linux based (and I haven't tried 
this) you could try adding a nohup and background the task for example 
rather than doing:


system('updatedb');

try

system('nohup updatedb &');

It should background the task and let it continue running even when the 
php script finishes it's execution. Like I said I haven't tested it. As 
a side note I used 'updatedb' in the example because it was the longest 
running task I could think of off the top of my head and requires root 
priveledges... You really shouldn't run your scripts as root. *A public 
server announcement*


Alberto García Gómez wrote:

Fellows:

I'm experimenting problems with a call that I made to exec or system. The 
problem is that the script await for the function finish and that take's a lot 
of time.

I need a way to use those functions in order to continue without await for it.

Saludos Fraternales
_
Atte.
Alberto García Gómez M:.M:.
Administrador de Redes/Webmaster
IPI "Carlos Marx", Matanzas. Cuba.
  



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



[PHP] EXEC and SYSTEM delay

2009-07-08 Thread Alberto García Gómez
Fellows:

I'm experimenting problems with a call that I made to exec or system. The 
problem is that the script await for the function finish and that take's a lot 
of time.

I need a way to use those functions in order to continue without await for it.

Saludos Fraternales
_
Atte.
Alberto García Gómez M:.M:.
Administrador de Redes/Webmaster
IPI "Carlos Marx", Matanzas. Cuba.

[PHP] Re: php exec()

2008-11-07 Thread Michelle Konzack
Am 2008-11-03 13:28:27, schrieb cheesiong:
> hi Chris,
>  thank you. i change the path and change the httpd.conf LogLevel to debug
> then restart apache.
>  but nothing is change from the output or the error log.
>  basically it is still not working.
> 
> this is weird, isn't it. the apache is run with Daemon, but i already change
> the chmod to 777. should not be a problem.

There are programs which EXPECT to  have  a  terminal  for  its  output,
otherwise they refuse to to anything...

Sometimes you can fool programs using the weird thing like:

exec('ipkg-cl --version >/dev/stdout 2>&1', $output);

This looks a little bit bizzar, but I have to tools which NEED it.
However, I am not the author ot this tools.

Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
+49/177/935194750, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: [PHP] php exec()

2008-11-03 Thread Stut

On 3 Nov 2008, at 08:06, cheesiong wrote:

i tried you suggestion, with
lalala.txt');?>
the lalala.txt was created but the file is empty.

anymore suggestion?


Try...

&1');?>

It's not uncommon for CLI utilities to output their banner on stderr  
so it doesn't get included when the output is piped elsewhere.


-Stut

--
http://stut.net/

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



Re: [PHP] php exec()

2008-11-03 Thread Zoltan Ormandi

Hi,

I'm not a Linux guru, so maybe my question is stupid, but are you sure 
the command prints its output to the *standard* output?


Z


cheesiong wrote:

hi ash,
 i tried you suggestion, with
lalala.txt');?>
the lalala.txt was created but the file is empty.

anymore suggestion?
thank you.

regards,-keo

On Mon, Nov 3, 2008 at 3:29 PM, Ashley Sheridan <[EMAIL PROTECTED]>wrote:

  

On Mon, 2008-11-03 at 15:21 +0800, cheesiong wrote:


hi Chris,
 i found out that when execute ipkg, the return is before the header.

root [ /srv/www/test ]# /program/php-5.2.6/bin/php-cgi ipkg.php
ipkg version 0.99.163
X-Powered-By: PHP/5.2.6
Content-type: text/html

Array
(
)


which is different than the whoami program.
root [ /srv/www/test ]# /program/php-5.2.6/bin/php-cgi whoami.php
X-Powered-By: PHP/5.2.6
Content-type: text/html

the result of execwhoami is
root


can you see the different?

regards,-keo


On Mon, Nov 3, 2008 at 2:12 PM, cheesiong <[EMAIL PROTECTED]>
  

wrote:


hi Chris,
 i did try,
below is the continouos output from prompt when i do su.

root [ /srv/www/test ]# su daemon
root [ /srv/www/test ]#

i didnt manage to switch user.
i will create an user... so that i can switch to it.

i created a user call lfs into group lfs.
able to execute ipkg-cl and /program//ipkg-ck --version.

then i change the httpd.conf to start apache with lfs and execute the


php


script to exec ipkg-cl --version.
basically it is not working.

root [ /srv/www/test ]# groupadd lfs
root [ /srv/www/test ]# useradd -s /bin/bash -g lfs -m -k /dev/null lfs
root [ /srv/www/test ]# passwd lfs
Changing password for lfs
Enter the new password (minimum of 5, maximum of 127 characters)
Please use a combination of upper and lower case letters and numbers.
New password:
Bad password: too short.
Warning: weak password (enter it again to use it anyway).
New password:
Re-enter new password:
Password changed.
root [ /srv/www/test ]# su lfs
bash-3.2$ ipkg-cl --version
ipkg version 0.99.163
bash-3.2$ /program/ipkg-0.99.163/bin/ipkg-cl --version
ipkg version 0.99.163
bash-3.2$

lfs  13615  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/
lfs  13616  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/
lfs  13617  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/
lfs  13618  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/
lfs  13619  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/


so not the user right problem, am i right ?

regards,-keo


On Mon, Nov 3, 2008 at 1:59 PM, Chris <[EMAIL PROTECTED]> wrote:



cheesiong wrote:

  

hi Chris,
 my linux system is LFS that i build from scratch.
 i cant su to daemon.

 below is my /etc/passwd:
root [ /srv/www/test ]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
daemon:x:6:6:daemon:/dev/null:/bin/false



Change it, su, change it back. Looking at apache logs won't tell you
  

much


if you don't try something.

Are you running selinux?

 ] /opt/ipkg-0.99.163/bin/ipkg-cl: Permission
  

denied, referer: http://169.254.0.101/test/



That one's pretty easy.


--
Postgresql & php tutorials
http://www.designmagick.com/


  

What about making an exec call, but piping the results of that call to a
text file. That way, it will be in a file that is easily accessed from
other parts of your site. I'm not sure which is more expensive, a call
to ifconfig, or a file read.


Ash
www.ashleysheridan.co.uk





  


Re: [PHP] php exec()

2008-11-03 Thread cheesiong
hi ash,
 i tried you suggestion, with
lalala.txt');?>
the lalala.txt was created but the file is empty.

anymore suggestion?
thank you.

regards,-keo

On Mon, Nov 3, 2008 at 3:29 PM, Ashley Sheridan <[EMAIL PROTECTED]>wrote:

> On Mon, 2008-11-03 at 15:21 +0800, cheesiong wrote:
> > hi Chris,
> >  i found out that when execute ipkg, the return is before the header.
> >
> > root [ /srv/www/test ]# /program/php-5.2.6/bin/php-cgi ipkg.php
> > ipkg version 0.99.163
> > X-Powered-By: PHP/5.2.6
> > Content-type: text/html
> >
> > Array
> > (
> > )
> >
> >
> > which is different than the whoami program.
> > root [ /srv/www/test ]# /program/php-5.2.6/bin/php-cgi whoami.php
> > X-Powered-By: PHP/5.2.6
> > Content-type: text/html
> >
> > the result of execwhoami is
> > root
> >
> >
> > can you see the different?
> >
> > regards,-keo
> >
> >
> > On Mon, Nov 3, 2008 at 2:12 PM, cheesiong <[EMAIL PROTECTED]>
> wrote:
> >
> > > hi Chris,
> > >  i did try,
> > > below is the continouos output from prompt when i do su.
> > >
> > > root [ /srv/www/test ]# su daemon
> > > root [ /srv/www/test ]#
> > >
> > > i didnt manage to switch user.
> > > i will create an user... so that i can switch to it.
> > >
> > > i created a user call lfs into group lfs.
> > > able to execute ipkg-cl and /program//ipkg-ck --version.
> > >
> > > then i change the httpd.conf to start apache with lfs and execute the
> php
> > > script to exec ipkg-cl --version.
> > > basically it is not working.
> > >
> > > root [ /srv/www/test ]# groupadd lfs
> > > root [ /srv/www/test ]# useradd -s /bin/bash -g lfs -m -k /dev/null lfs
> > > root [ /srv/www/test ]# passwd lfs
> > > Changing password for lfs
> > > Enter the new password (minimum of 5, maximum of 127 characters)
> > > Please use a combination of upper and lower case letters and numbers.
> > > New password:
> > > Bad password: too short.
> > > Warning: weak password (enter it again to use it anyway).
> > > New password:
> > > Re-enter new password:
> > > Password changed.
> > > root [ /srv/www/test ]# su lfs
> > > bash-3.2$ ipkg-cl --version
> > > ipkg version 0.99.163
> > > bash-3.2$ /program/ipkg-0.99.163/bin/ipkg-cl --version
> > > ipkg version 0.99.163
> > > bash-3.2$
> > >
> > > lfs  13615  0.0  0.3   3684  1344 ?S14:06   0:00
> > > /program/httpd-2.2.9/bin/
> > > lfs  13616  0.0  0.3   3684  1344 ?S14:06   0:00
> > > /program/httpd-2.2.9/bin/
> > > lfs  13617  0.0  0.3   3684  1344 ?S14:06   0:00
> > > /program/httpd-2.2.9/bin/
> > > lfs  13618  0.0  0.3   3684  1344 ?S14:06   0:00
> > > /program/httpd-2.2.9/bin/
> > > lfs  13619  0.0  0.3   3684  1344 ?S14:06   0:00
> > > /program/httpd-2.2.9/bin/
> > >
> > >
> > > so not the user right problem, am i right ?
> > >
> > > regards,-keo
> > >
> > >
> > > On Mon, Nov 3, 2008 at 1:59 PM, Chris <[EMAIL PROTECTED]> wrote:
> > >
> > >> cheesiong wrote:
> > >>
> > >>> hi Chris,
> > >>>  my linux system is LFS that i build from scratch.
> > >>>  i cant su to daemon.
> > >>>
> > >>>  below is my /etc/passwd:
> > >>> root [ /srv/www/test ]# cat /etc/passwd
> > >>> root:x:0:0:root:/root:/bin/bash
> > >>> nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
> > >>> sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
> > >>> daemon:x:6:6:daemon:/dev/null:/bin/false
> > >>>
> > >>
> > >> Change it, su, change it back. Looking at apache logs won't tell you
> much
> > >> if you don't try something.
> > >>
> > >> Are you running selinux?
> > >>
> > >>  ] /opt/ipkg-0.99.163/bin/ipkg-cl: Permission
> > >>> denied, referer: http://169.254.0.101/test/
> > >>>
> > >>
> > >> That one's pretty easy.
> > >>
> > >>
> > >> --
> > >> Postgresql & php tutorials
> > >> http://www.designmagick.com/
> > >>
> > >>
> > >
> What about making an exec call, but piping the results of that call to a
> text file. That way, it will be in a file that is easily accessed from
> other parts of your site. I'm not sure which is more expensive, a call
> to ifconfig, or a file read.
>
>
> Ash
> www.ashleysheridan.co.uk
>
>


Re: [PHP] php exec()

2008-11-02 Thread Ashley Sheridan
On Mon, 2008-11-03 at 15:21 +0800, cheesiong wrote:
> hi Chris,
>  i found out that when execute ipkg, the return is before the header.
> 
> root [ /srv/www/test ]# /program/php-5.2.6/bin/php-cgi ipkg.php
> ipkg version 0.99.163
> X-Powered-By: PHP/5.2.6
> Content-type: text/html
> 
> Array
> (
> )
> 
> 
> which is different than the whoami program.
> root [ /srv/www/test ]# /program/php-5.2.6/bin/php-cgi whoami.php
> X-Powered-By: PHP/5.2.6
> Content-type: text/html
> 
> the result of execwhoami is
> root
> 
> 
> can you see the different?
> 
> regards,-keo
> 
> 
> On Mon, Nov 3, 2008 at 2:12 PM, cheesiong <[EMAIL PROTECTED]> wrote:
> 
> > hi Chris,
> >  i did try,
> > below is the continouos output from prompt when i do su.
> >
> > root [ /srv/www/test ]# su daemon
> > root [ /srv/www/test ]#
> >
> > i didnt manage to switch user.
> > i will create an user... so that i can switch to it.
> >
> > i created a user call lfs into group lfs.
> > able to execute ipkg-cl and /program//ipkg-ck --version.
> >
> > then i change the httpd.conf to start apache with lfs and execute the php
> > script to exec ipkg-cl --version.
> > basically it is not working.
> >
> > root [ /srv/www/test ]# groupadd lfs
> > root [ /srv/www/test ]# useradd -s /bin/bash -g lfs -m -k /dev/null lfs
> > root [ /srv/www/test ]# passwd lfs
> > Changing password for lfs
> > Enter the new password (minimum of 5, maximum of 127 characters)
> > Please use a combination of upper and lower case letters and numbers.
> > New password:
> > Bad password: too short.
> > Warning: weak password (enter it again to use it anyway).
> > New password:
> > Re-enter new password:
> > Password changed.
> > root [ /srv/www/test ]# su lfs
> > bash-3.2$ ipkg-cl --version
> > ipkg version 0.99.163
> > bash-3.2$ /program/ipkg-0.99.163/bin/ipkg-cl --version
> > ipkg version 0.99.163
> > bash-3.2$
> >
> > lfs  13615  0.0  0.3   3684  1344 ?S14:06   0:00
> > /program/httpd-2.2.9/bin/
> > lfs  13616  0.0  0.3   3684  1344 ?S14:06   0:00
> > /program/httpd-2.2.9/bin/
> > lfs  13617  0.0  0.3   3684  1344 ?S14:06   0:00
> > /program/httpd-2.2.9/bin/
> > lfs  13618  0.0  0.3   3684  1344 ?S14:06   0:00
> > /program/httpd-2.2.9/bin/
> > lfs  13619  0.0  0.3   3684  1344 ?S14:06   0:00
> > /program/httpd-2.2.9/bin/
> >
> >
> > so not the user right problem, am i right ?
> >
> > regards,-keo
> >
> >
> > On Mon, Nov 3, 2008 at 1:59 PM, Chris <[EMAIL PROTECTED]> wrote:
> >
> >> cheesiong wrote:
> >>
> >>> hi Chris,
> >>>  my linux system is LFS that i build from scratch.
> >>>  i cant su to daemon.
> >>>
> >>>  below is my /etc/passwd:
> >>> root [ /srv/www/test ]# cat /etc/passwd
> >>> root:x:0:0:root:/root:/bin/bash
> >>> nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
> >>> sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
> >>> daemon:x:6:6:daemon:/dev/null:/bin/false
> >>>
> >>
> >> Change it, su, change it back. Looking at apache logs won't tell you much
> >> if you don't try something.
> >>
> >> Are you running selinux?
> >>
> >>  ] /opt/ipkg-0.99.163/bin/ipkg-cl: Permission
> >>> denied, referer: http://169.254.0.101/test/
> >>>
> >>
> >> That one's pretty easy.
> >>
> >>
> >> --
> >> Postgresql & php tutorials
> >> http://www.designmagick.com/
> >>
> >>
> >
What about making an exec call, but piping the results of that call to a
text file. That way, it will be in a file that is easily accessed from
other parts of your site. I'm not sure which is more expensive, a call
to ifconfig, or a file read.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] php exec()

2008-11-02 Thread cheesiong
hi Chris,
 i found out that when execute ipkg, the return is before the header.

root [ /srv/www/test ]# /program/php-5.2.6/bin/php-cgi ipkg.php
ipkg version 0.99.163
X-Powered-By: PHP/5.2.6
Content-type: text/html

Array
(
)


which is different than the whoami program.
root [ /srv/www/test ]# /program/php-5.2.6/bin/php-cgi whoami.php
X-Powered-By: PHP/5.2.6
Content-type: text/html

the result of execwhoami is
root


can you see the different?

regards,-keo


On Mon, Nov 3, 2008 at 2:12 PM, cheesiong <[EMAIL PROTECTED]> wrote:

> hi Chris,
>  i did try,
> below is the continouos output from prompt when i do su.
>
> root [ /srv/www/test ]# su daemon
> root [ /srv/www/test ]#
>
> i didnt manage to switch user.
> i will create an user... so that i can switch to it.
>
> i created a user call lfs into group lfs.
> able to execute ipkg-cl and /program//ipkg-ck --version.
>
> then i change the httpd.conf to start apache with lfs and execute the php
> script to exec ipkg-cl --version.
> basically it is not working.
>
> root [ /srv/www/test ]# groupadd lfs
> root [ /srv/www/test ]# useradd -s /bin/bash -g lfs -m -k /dev/null lfs
> root [ /srv/www/test ]# passwd lfs
> Changing password for lfs
> Enter the new password (minimum of 5, maximum of 127 characters)
> Please use a combination of upper and lower case letters and numbers.
> New password:
> Bad password: too short.
> Warning: weak password (enter it again to use it anyway).
> New password:
> Re-enter new password:
> Password changed.
> root [ /srv/www/test ]# su lfs
> bash-3.2$ ipkg-cl --version
> ipkg version 0.99.163
> bash-3.2$ /program/ipkg-0.99.163/bin/ipkg-cl --version
> ipkg version 0.99.163
> bash-3.2$
>
> lfs  13615  0.0  0.3   3684  1344 ?S14:06   0:00
> /program/httpd-2.2.9/bin/
> lfs  13616  0.0  0.3   3684  1344 ?S14:06   0:00
> /program/httpd-2.2.9/bin/
> lfs  13617  0.0  0.3   3684  1344 ?S14:06   0:00
> /program/httpd-2.2.9/bin/
> lfs  13618  0.0  0.3   3684  1344 ?S14:06   0:00
> /program/httpd-2.2.9/bin/
> lfs  13619  0.0  0.3   3684  1344 ?S14:06   0:00
> /program/httpd-2.2.9/bin/
>
>
> so not the user right problem, am i right ?
>
> regards,-keo
>
>
> On Mon, Nov 3, 2008 at 1:59 PM, Chris <[EMAIL PROTECTED]> wrote:
>
>> cheesiong wrote:
>>
>>> hi Chris,
>>>  my linux system is LFS that i build from scratch.
>>>  i cant su to daemon.
>>>
>>>  below is my /etc/passwd:
>>> root [ /srv/www/test ]# cat /etc/passwd
>>> root:x:0:0:root:/root:/bin/bash
>>> nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
>>> sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
>>> daemon:x:6:6:daemon:/dev/null:/bin/false
>>>
>>
>> Change it, su, change it back. Looking at apache logs won't tell you much
>> if you don't try something.
>>
>> Are you running selinux?
>>
>>  ] /opt/ipkg-0.99.163/bin/ipkg-cl: Permission
>>> denied, referer: http://169.254.0.101/test/
>>>
>>
>> That one's pretty easy.
>>
>>
>> --
>> Postgresql & php tutorials
>> http://www.designmagick.com/
>>
>>
>


Re: [PHP] php exec()

2008-11-02 Thread cheesiong
hi Chris,
 i did try,
below is the continouos output from prompt when i do su.

root [ /srv/www/test ]# su daemon
root [ /srv/www/test ]#

i didnt manage to switch user.
i will create an user... so that i can switch to it.

i created a user call lfs into group lfs.
able to execute ipkg-cl and /program//ipkg-ck --version.

then i change the httpd.conf to start apache with lfs and execute the php
script to exec ipkg-cl --version.
basically it is not working.

root [ /srv/www/test ]# groupadd lfs
root [ /srv/www/test ]# useradd -s /bin/bash -g lfs -m -k /dev/null lfs
root [ /srv/www/test ]# passwd lfs
Changing password for lfs
Enter the new password (minimum of 5, maximum of 127 characters)
Please use a combination of upper and lower case letters and numbers.
New password:
Bad password: too short.
Warning: weak password (enter it again to use it anyway).
New password:
Re-enter new password:
Password changed.
root [ /srv/www/test ]# su lfs
bash-3.2$ ipkg-cl --version
ipkg version 0.99.163
bash-3.2$ /program/ipkg-0.99.163/bin/ipkg-cl --version
ipkg version 0.99.163
bash-3.2$

lfs  13615  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/
lfs  13616  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/
lfs  13617  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/
lfs  13618  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/
lfs  13619  0.0  0.3   3684  1344 ?S14:06   0:00
/program/httpd-2.2.9/bin/


so not the user right problem, am i right ?

regards,-keo

On Mon, Nov 3, 2008 at 1:59 PM, Chris <[EMAIL PROTECTED]> wrote:

> cheesiong wrote:
>
>> hi Chris,
>>  my linux system is LFS that i build from scratch.
>>  i cant su to daemon.
>>
>>  below is my /etc/passwd:
>> root [ /srv/www/test ]# cat /etc/passwd
>> root:x:0:0:root:/root:/bin/bash
>> nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
>> sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
>> daemon:x:6:6:daemon:/dev/null:/bin/false
>>
>
> Change it, su, change it back. Looking at apache logs won't tell you much
> if you don't try something.
>
> Are you running selinux?
>
>  ] /opt/ipkg-0.99.163/bin/ipkg-cl: Permission denied,
>> referer: http://169.254.0.101/test/
>>
>
> That one's pretty easy.
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


Re: [PHP] php exec()

2008-11-02 Thread Chris

cheesiong wrote:

hi Chris,
 my linux system is LFS that i build from scratch.
 i cant su to daemon.

 below is my /etc/passwd:
root [ /srv/www/test ]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
daemon:x:6:6:daemon:/dev/null:/bin/false


Change it, su, change it back. Looking at apache logs won't tell you 
much if you don't try something.


Are you running selinux?

] /opt/ipkg-0.99.163/bin/ipkg-cl: Permission 
denied, referer: http://169.254.0.101/test/


That one's pretty easy.

--
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] php exec()

2008-11-02 Thread cheesiong
hi Chris,
 my linux system is LFS that i build from scratch.
 i cant su to daemon.

 below is my /etc/passwd:
root [ /srv/www/test ]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
daemon:x:6:6:daemon:/dev/null:/bin/false

i try to run the same thing in other platform:
it come out a more meaningful msg. i will trace from there.
any hint from you?

[EMAIL PROTECTED] test]#tail /opt/logs/error_log

[Mon Jun 23 12:06:24 2008] [error] [client 169.254.0.20] sh: , referer:
http://169.254.0.101/test/
[Mon Jun 23 12:06:24 2008] [error] [client 169.254.0.20]
/opt/ipkg-0.99.163/bin/ipkg-cl: Permission denied, referer:
http://169.254.0.101/test/
[Mon Jun 23 12:06:24 2008] [error] [client 169.254.0.20] , referer:
http://169.254.0.101/test/

regards,-keo

On Mon, Nov 3, 2008 at 1:45 PM, Chris <[EMAIL PROTECTED]> wrote:

> cheesiong wrote:
>
>> hi Chris,
>>  thank you. i change the path and change the httpd.conf LogLevel to debug
>> then restart apache.
>>  but nothing is change from the output or the error log.
>>  basically it is still not working.
>>
>> this is weird, isn't it. the apache is run with Daemon, but i already
>> change the chmod to 777. should not be a problem.
>>
>
> Log in as root then su to your apache user and run it from the command
> line. What happens?
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


Re: [PHP] php exec()

2008-11-02 Thread Chris

cheesiong wrote:

hi Chris,
 thank you. i change the path and change the httpd.conf LogLevel to 
debug then restart apache.

 but nothing is change from the output or the error log.
 basically it is still not working.

this is weird, isn't it. the apache is run with Daemon, but i already 
change the chmod to 777. should not be a problem.


Log in as root then su to your apache user and run it from the command 
line. What happens?


--
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] php exec()

2008-11-02 Thread cheesiong
hi Chris,
 thank you. i change the path and change the httpd.conf LogLevel to debug
then restart apache.
 but nothing is change from the output or the error log.
 basically it is still not working.

this is weird, isn't it. the apache is run with Daemon, but i already change
the chmod to 777. should not be a problem.

regards,-keo

On Mon, Nov 3, 2008 at 1:19 PM, Chris <[EMAIL PROTECTED]> wrote:

> cheesiong wrote:
>
>> hi Chris,
>> i change the script to:
>> > error_reporting(E_ALL);
>> ini_set('display_errors', true);
>> $output = array();
>> exec('ipkg-cl --version', $output);
>>
>> print_r($output);
>> ?>
>>
>> the output from browser:
>> array()
>>
>> other stuff remain the same. can i conclude php program is not a problem
>> here?
>>
>
> It could be a path problem still even though you put it in /usr/bin/
>
> try a full path (recommended anyway):
>
> exec('/usr/bin/ipkg-cl --version', $output);
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


Re: [PHP] php exec()

2008-11-02 Thread Chris

cheesiong wrote:

hi Chris,
i change the script to:


the output from browser:
array()

other stuff remain the same. can i conclude php program is not a problem 
here?


It could be a path problem still even though you put it in /usr/bin/

try a full path (recommended anyway):

exec('/usr/bin/ipkg-cl --version', $output);

--
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] php exec()

2008-11-02 Thread cheesiong
hi Chris,
i change the script to:


the output from browser:
array()

other stuff remain the same. can i conclude php program is not a problem
here?

i will try to use other server to see if it is server inheritance.
and will try to increase errorlog level to see what is the problem.

regards,-keo

On Mon, Nov 3, 2008 at 1:03 PM, Chris <[EMAIL PROTECTED]> wrote:

> cheesiong wrote:
>
>> hi Chris,
>> thank you.
>> it is not working as well.
>> i copy the ipkg-cl into /usr/bin
>>
>
> add
>
> error_reporting(E_ALL);
>
> and
>
> ini_set('display_errors', true);
>
> to the top of your script.
>
> any errors/warnings/whatever show up?
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


Re: [PHP] php exec()

2008-11-02 Thread Chris

cheesiong wrote:

hi Chris,
thank you.
it is not working as well.
i copy the ipkg-cl into /usr/bin


add

error_reporting(E_ALL);

and

ini_set('display_errors', true);

to the top of your script.

any errors/warnings/whatever show up?

--
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] php exec()

2008-11-02 Thread cheesiong
hi Chris,
thank you.
it is not working as well.
i copy the ipkg-cl into /usr/bin

do i need to set anything in the httpd.conf on the  directive?
i am running apache-2.2.9.

this is code copy from you suggestion:


output from browser:
Array ( )

output from prompt if i execute on the linux system:
root [ /srv/www/test ]# ipkg-cl --version
ipkg version 0.99.163


server error log:
root [ /srv/www/test ]# tail /program/httpd-2.2.9/logs/error_log

regards,-keo

[Mon Nov 03 12:50:00 2008] [error] [client 10.104.9.220] ipkg version
0.99.163

On Mon, Nov 3, 2008 at 12:33 PM, Chris <[EMAIL PROTECTED]> wrote:

>
>  the output from the browser is the same and not the expecting version of
>> the
>> ipkg-cl.
>> then i tried to echo exec('ifconfig'); the output is the same also.
>>
>
> You need to do this:
>
> $output = array();
> exec('/program/', $output);
>
> for it to put the results of running the command into the $output array.
>
> Then you can print it:
>
> print_r($output);
>
>
> This is in the manual: http://au.php.net/manual/en/function.exec.php
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


Re: [PHP] php exec()

2008-11-02 Thread Chris



the output from the browser is the same and not the expecting version of the
ipkg-cl.
then i tried to echo exec('ifconfig'); the output is the same also.


You need to do this:

$output = array();
exec('/program/', $output);

for it to put the results of running the command into the $output array.

Then you can print it:

print_r($output);


This is in the manual: http://au.php.net/manual/en/function.exec.php

--
Postgresql & php tutorials
http://www.designmagick.com/


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



[PHP] Re: php exec()

2008-11-02 Thread cheesiong
i try to use the system() function, i found the the last line of the
ifconfig is actually nothing.
but i still cannot execute the ipkg-cl program. any idea?
thank you.

regards,-keo

On Mon, Nov 3, 2008 at 11:31 AM, cheesiong <[EMAIL PROTECTED]> wrote:

> hi all,
>  this is the first time i try out the mailing list. i hope to get help from
> here. thank you.
>
> i am facing a problem when i study exec() php function:
> i tried the example 1 on http://cn.php.net/manual/en/function.exec.php
>  // outputs the username that owns the running php/httpd process
> // (on a system with the "whoami" executable in the path)
> echo exec('whoami');
> ?>
>
> this is alright for me.
>
> when i added a line to the script
>  // outputs the username that owns the running php/httpd process
> // (on a system with the "whoami" executable in the path)
> echo exec('whoami');
> echo exec('/program/ipkg-0.99.163/bin/ipkg-cl --version');
> [echo exec('ifconfig');]
> ?>
>
> the output from the browser is the same and not the expecting version of
> the ipkg-cl.
> then i tried to echo exec('ifconfig'); the output is the same also.
>
> below is the output of server error log.
> root [ /srv/www/test ]# !tail
> tail /program/httpd-2.2.9/logs/error_log
>
> [Mon Nov 03 11:25:14 2008] [error] [client 10.104.9.220] ipkg version
> 0.99.163
>
> -
> ipkg-cl is executable. is chmod 777.
> root [ /srv/www/test ]# file /program/ipkg-0.99.163/bin/ipkg-cl
> /program/ipkg-0.99.163/bin/ipkg-cl: ELF 32-bit LSB executable, Intel 80386,
> version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared
> libs), not stripped
>
>
> i have tried to read more on the php net and have a few different trials. i
> do not have more idea now, i hope i can get someone help from here.
> thank you.
>
> regards,-keo
>
>
>
>


[PHP] php exec()

2008-11-02 Thread cheesiong
hi all,
 this is the first time i try out the mailing list. i hope to get help from
here. thank you.

i hope this email can reach the mail group as i use bluecolour.sz to sign on
the news group but using bluecolour to do all the emailing.

i am facing a problem when i study exec() php function:
i tried the example 1 on http://cn.php.net/manual/en/function.exec.php


this is alright for me.

when i added a line to the script


the output from the browser is the same and not the expecting version of the
ipkg-cl.
then i tried to echo exec('ifconfig'); the output is the same also.

below is the output of server error log.
root [ /srv/www/test ]# !tail
tail /program/httpd-2.2.9/logs/error_log

[Mon Nov 03 11:25:14 2008] [error] [client 10.104.9.220] ipkg version
0.99.163

-
ipkg-cl is executable. is chmod 777.
root [ /srv/www/test ]# file /program/ipkg-0.99.163/bin/ipkg-cl
/program/ipkg-0.99.163/bin/ipkg-cl: ELF 32-bit LSB executable, Intel 80386,
version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared
libs), not stripped


i have tried to read more on the php net and have a few different trials. i
do not have more idea now, i hope i can get someone help from here.
thank you.

regards,-keo


Re: Re: [PHP] exec() Error

2008-06-30 Thread zhiqi pan
use wget
exec("wget http://www.mysite.com/calculate.php";);
Only execute the php programe from "web"
exec("/usr/bin/php /.../calculate.php")



2008/6/27 Boyd, Todd M. <[EMAIL PROTECTED]>:

> > -Original Message-
> > From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, June 26, 2008 7:50 AM
> > To: Boyd, Todd M.; php-general@lists.php.net
> > Subject: RE: Re: [PHP] exec() Error
> >
> > Hi, Todd:
> >
> >It looks like I have some other errors in my Perl code, and I got
> it
> > fixed, switched the permission to 755, and made attempts to call it
> > using cURL through my working PHP script.
> >
> >Here is the code:
> >
> > // create a new cURL resource
> > $ch = curl_init();
> >
> > // set URL and other appropriate options
> > curl_setopt($ch, CURLOPT_URL, "http://192.168.10.63/total.cgi";);
> > curl_setopt($ch, CURLOPT_HEADER, false);
> >
> > // grab URL and pass it to the browser
> > curl_exec($ch);
> >
> > // close cURL resource, and free up system resources
> > curl_close($ch);
> >
> > This time, I do not get the "script" output from the script in
> > total.cgi, but I got
> >
> > Forbidden
> > You don't have permission to access /total.cgi on this server.
> >
> > I have switched the permission to both scripts at both servers. Is
> > there something wrong I have done here?
>
> Alice,
>
> I do not program in Perl, nor do I use CGI often enough to help you much
> here. However, it looks to me like it's a webserver issue, and has
> nothing to do with your code itself. Whatever CGI module is being used
> must probably be told that total.cgi needs granular permissions.
>
> Your web administrator will be able to help you much more than I can at
> this point.
>
> HTH,
>
>
> Todd Boyd
> Web Programmer
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
潘治岐
手机: 13621265301
Email: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]


RE: Re: [PHP] exec() Error

2008-06-27 Thread Boyd, Todd M.
> -Original Message-
> From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 26, 2008 7:50 AM
> To: Boyd, Todd M.; php-general@lists.php.net
> Subject: RE: Re: [PHP] exec() Error
> 
> Hi, Todd:
> 
>It looks like I have some other errors in my Perl code, and I got
it
> fixed, switched the permission to 755, and made attempts to call it
> using cURL through my working PHP script.
> 
>Here is the code:
> 
> // create a new cURL resource
> $ch = curl_init();
> 
> // set URL and other appropriate options
> curl_setopt($ch, CURLOPT_URL, "http://192.168.10.63/total.cgi";);
> curl_setopt($ch, CURLOPT_HEADER, false);
> 
> // grab URL and pass it to the browser
> curl_exec($ch);
> 
> // close cURL resource, and free up system resources
> curl_close($ch);
> 
> This time, I do not get the "script" output from the script in
> total.cgi, but I got
> 
> Forbidden
> You don't have permission to access /total.cgi on this server.
> 
> I have switched the permission to both scripts at both servers. Is
> there something wrong I have done here?

Alice,

I do not program in Perl, nor do I use CGI often enough to help you much
here. However, it looks to me like it's a webserver issue, and has
nothing to do with your code itself. Whatever CGI module is being used
must probably be told that total.cgi needs granular permissions.

Your web administrator will be able to help you much more than I can at
this point.

HTH,


Todd Boyd
Web Programmer




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



Re: Re: [PHP] exec() Error

2008-06-26 Thread Jason Murray
Alice,

If you are already set 755 on the CGI, it looks like it might be a webserver
configuration issue.

If you are using Apache (I'm assuming you are) you might want to take a look
at

http://httpd.apache.org/docs/2.0/howto/cgi.html#configuringapachetopermitcgi

for some hints on how to make sure that the server configuration is proper
for using CGI scripts.

Regards

Jason

On Thu, Jun 26, 2008 at 8:50 AM, Wei, Alice J. <[EMAIL PROTECTED]> wrote:

> Hi, Todd:
>
>   It looks like I have some other errors in my Perl code, and I got it
> fixed, switched the permission to 755, and made attempts to call it using
> cURL through my working PHP script.
>
>   Here is the code:
>
> // create a new cURL resource
> $ch = curl_init();
>
> // set URL and other appropriate options
> curl_setopt($ch, CURLOPT_URL, "http://192.168.10.63/total.cgi";);
> curl_setopt($ch, CURLOPT_HEADER, false);
>
> // grab URL and pass it to the browser
> curl_exec($ch);
>
> // close cURL resource, and free up system resources
> curl_close($ch);
>
> This time, I do not get the "script" output from the script in total.cgi,
> but I got
>
> Forbidden
> You don't have permission to access /total.cgi on this server.
>
> I have switched the permission to both scripts at both servers. Is there
> something wrong I have done here?
>
> Thanks again for your help.
>
> Alice
> ==
> Alice Wei
> MIS 2009
> School of Library and Information Science
> Indiana University Bloomington
> [EMAIL PROTECTED]
> ________
> From: Boyd, Todd M. [EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 5:07 PM
> To: Wei, Alice J.; php-general@lists.php.net
> Subject: RE: Re: [PHP] exec() Error
>
> > -Original Message-
> > From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, June 25, 2008 3:31 PM
> > To: Boyd, Todd M.; Per Jessen; php-general@lists.php.net
> > Subject: RE: Re: [PHP] exec() Error
>
> ---8<--- snip
>
> > > Well, "http://www.mysite.com/calculate.php"; is not an executable.
> > Try
> > > this instead:
> > >
> > > exec("php /calculate.php");
> >
> > I still don't think this is how exec() should be used when executing
> > remote PHP scripts via HTTP, since the web server is not going to give
> > you the underlying code simply because you're calling the URL from PHP
> > and not your web browser. User-Agent tags do not a secure connection
> > make.
> >
> > Perhaps doing a wget and directing it to /dev/null (if you're on *nix)
> > would be appropriate to invoke a remote script and pass it parameters.
> > Hell, even wget to standard output if you want, and use that as your
> > "result code." It's basically doing what cURL does, but outside of the
> > PHP script itself.
> >
> > Anyway, I digress. My point is that exec("php
> > http://mysite.com/script.php";) will fail, since it will be reading the
> > remote script's OUTPUT, and not the remote script's SOURCE CODE.
> >
> >I dont' know how come his code works either. I figured that exec()
> > is not going to get me anywhere when I have it stored remotely.
> >I am now using cURL instead of using exec(), since it is doing a
> lot
> > closer to what I initiated. I am not sure if I should have a new
> thread
> > for this, but I found that things start to get a little weird when I
> > tried to do cURL with Perl files inside. The PHP only brings me back
> > Perl code and not the processed content. Is this something I should
> not
> > be doing with cURL? It seems to do quite a bit of powerful processing
> > when I wrote everything in PHP and have it stored remotely.
>
> Alice,
>
> If it's returning the code instead of the processed content, then it
> means that the webserver which houses the Perl script is not
> executing/parsing it. You should check with the administrator of the
> remote webserver to see if they have a Perl module installed, and if it
> is configured properly for your web app.
>
> HTH,
>
>
> Todd Boyd
> Web Programmer
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


RE: RE: Re: [PHP] exec() Error

2008-06-26 Thread Per Jessen
Boyd, Todd M. wrote:

>> >PHP or other programming languages? For example, C, Python, or Perl.
>> 
>> And that works just fine using exec().
> 
> Well... if she was trying to execute *LOCAL* PHP code from within a
> PHP script that was already running (which she was not), why would you
> suggest that she use exec() instead of include()?

If she'd only asked about PHP, include() would be the answer, but she
also included C and Perl in the options. 

> I think the issue has been obfuscated. Nevertheless, she's on the
> right track to making her program do what she wants to.

Yup. 


/Per Jessen, Zürich


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



RE: RE: Re: [PHP] exec() Error

2008-06-26 Thread Boyd, Todd M.
> -Original Message-
> From: Per Jessen [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 26, 2008 1:11 AM
> To: php-general@lists.php.net
> Subject: RE: Re: [PHP] exec() Error
> 
> Boyd, Todd M. wrote:
> 
> >>
> >> Well, "http://www.mysite.com/calculate.php"; is not an executable.
> >> Try this instead:
> >>
> >> exec("php /calculate.php");
> >
> > I still don't think this is how exec() should be used when executing
> > remote PHP scripts via HTTP, since the web server is not going to
> give
> > you the underlying code simply because you're calling the URL from
> PHP
> > and not your web browser. User-Agent tags do not a secure connection
> > make.
> 
> That's not what Alice asked for though.  She did mention that a remote
> call would be made somewhere, but her question was:
> 
> >Has anyone tried using exec() successfully in PHP to execute files
> from
> >PHP or other programming languages? For example, C, Python, or Perl.
> 
> And that works just fine using exec().

Well... if she was trying to execute *LOCAL* PHP code from within a PHP script 
that was already running (which she was not), why would you suggest that she 
use exec() instead of include()?

I think the issue has been obfuscated. Nevertheless, she's on the right track 
to making her program do what she wants to.

Win-win.


Todd Boyd
Web Programmer





RE: Re: [PHP] exec() Error

2008-06-26 Thread Wei, Alice J.
Hi, Todd:

   It looks like I have some other errors in my Perl code, and I got it fixed, 
switched the permission to 755, and made attempts to call it using cURL through 
my working PHP script.

   Here is the code:

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://192.168.10.63/total.cgi";);
curl_setopt($ch, CURLOPT_HEADER, false);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

This time, I do not get the "script" output from the script in total.cgi, but I 
got

Forbidden
You don't have permission to access /total.cgi on this server.

I have switched the permission to both scripts at both servers. Is there 
something wrong I have done here?

Thanks again for your help.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

From: Boyd, Todd M. [EMAIL PROTECTED]
Sent: Wednesday, June 25, 2008 5:07 PM
To: Wei, Alice J.; php-general@lists.php.net
Subject: RE: Re: [PHP] exec() Error

> -Original Message-
> From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 3:31 PM
> To: Boyd, Todd M.; Per Jessen; php-general@lists.php.net
> Subject: RE: Re: [PHP] exec() Error

---8<--- snip

> > Well, "http://www.mysite.com/calculate.php"; is not an executable.
> Try
> > this instead:
> >
> > exec("php /calculate.php");
>
> I still don't think this is how exec() should be used when executing
> remote PHP scripts via HTTP, since the web server is not going to give
> you the underlying code simply because you're calling the URL from PHP
> and not your web browser. User-Agent tags do not a secure connection
> make.
>
> Perhaps doing a wget and directing it to /dev/null (if you're on *nix)
> would be appropriate to invoke a remote script and pass it parameters.
> Hell, even wget to standard output if you want, and use that as your
> "result code." It's basically doing what cURL does, but outside of the
> PHP script itself.
>
> Anyway, I digress. My point is that exec("php
> http://mysite.com/script.php";) will fail, since it will be reading the
> remote script's OUTPUT, and not the remote script's SOURCE CODE.
>
>I dont' know how come his code works either. I figured that exec()
> is not going to get me anywhere when I have it stored remotely.
>I am now using cURL instead of using exec(), since it is doing a
lot
> closer to what I initiated. I am not sure if I should have a new
thread
> for this, but I found that things start to get a little weird when I
> tried to do cURL with Perl files inside. The PHP only brings me back
> Perl code and not the processed content. Is this something I should
not
> be doing with cURL? It seems to do quite a bit of powerful processing
> when I wrote everything in PHP and have it stored remotely.

Alice,

If it's returning the code instead of the processed content, then it
means that the webserver which houses the Perl script is not
executing/parsing it. You should check with the administrator of the
remote webserver to see if they have a Perl module installed, and if it
is configured properly for your web app.

HTH,


Todd Boyd
Web Programmer




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



RE: Re: [PHP] exec() Error

2008-06-25 Thread Per Jessen
Boyd, Todd M. wrote:

>> 
>> Well, "http://www.mysite.com/calculate.php"; is not an executable. 
>> Try this instead:
>> 
>> exec("php /calculate.php");
> 
> I still don't think this is how exec() should be used when executing
> remote PHP scripts via HTTP, since the web server is not going to give
> you the underlying code simply because you're calling the URL from PHP
> and not your web browser. User-Agent tags do not a secure connection
> make.

That's not what Alice asked for though.  She did mention that a remote
call would be made somewhere, but her question was:

>Has anyone tried using exec() successfully in PHP to execute files from
>PHP or other programming languages? For example, C, Python, or Perl. 

And that works just fine using exec(). 


/Per Jessen, Zürich


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



RE: Re: [PHP] exec() Error

2008-06-25 Thread Boyd, Todd M.
> -Original Message-
> From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 3:31 PM
> To: Boyd, Todd M.; Per Jessen; php-general@lists.php.net
> Subject: RE: Re: [PHP] exec() Error

---8<--- snip

> > Well, "http://www.mysite.com/calculate.php"; is not an executable.
> Try
> > this instead:
> >
> > exec("php /calculate.php");
> 
> I still don't think this is how exec() should be used when executing
> remote PHP scripts via HTTP, since the web server is not going to give
> you the underlying code simply because you're calling the URL from PHP
> and not your web browser. User-Agent tags do not a secure connection
> make.
> 
> Perhaps doing a wget and directing it to /dev/null (if you're on *nix)
> would be appropriate to invoke a remote script and pass it parameters.
> Hell, even wget to standard output if you want, and use that as your
> "result code." It's basically doing what cURL does, but outside of the
> PHP script itself.
> 
> Anyway, I digress. My point is that exec("php
> http://mysite.com/script.php";) will fail, since it will be reading the
> remote script's OUTPUT, and not the remote script's SOURCE CODE.
> 
>I dont' know how come his code works either. I figured that exec()
> is not going to get me anywhere when I have it stored remotely.
>I am now using cURL instead of using exec(), since it is doing a
lot
> closer to what I initiated. I am not sure if I should have a new
thread
> for this, but I found that things start to get a little weird when I
> tried to do cURL with Perl files inside. The PHP only brings me back
> Perl code and not the processed content. Is this something I should
not
> be doing with cURL? It seems to do quite a bit of powerful processing
> when I wrote everything in PHP and have it stored remotely.

Alice,

If it's returning the code instead of the processed content, then it
means that the webserver which houses the Perl script is not
executing/parsing it. You should check with the administrator of the
remote webserver to see if they have a Perl module installed, and if it
is configured properly for your web app.

HTH,


Todd Boyd
Web Programmer




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



RE: Re: [PHP] exec() Error

2008-06-25 Thread Wei, Alice J.

From: Boyd, Todd M. [EMAIL PROTECTED]
Sent: Wednesday, June 25, 2008 4:25 PM
To: Per Jessen; php-general@lists.php.net
Subject: RE:  Re: [PHP] exec() Error

> -Original Message-
> From: Per Jessen [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 2:48 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] exec() Error
>
> Wei, Alice J. wrote:
>
> > I have got a task from my client asking me to build something
> > that allows the variables in the PHP file passed to another
> > PHP file or a file in a different computer language to
> perform
> > some operations on another remote machine. According to my
> > client, he calls this behind the scenes to avoid users screw
> > up the front end, and I am hoping that I can produce one
> > single script, and have it execute some script without the
> > user pushing any button. Has anyone tried using exec()
> > successfully in PHP to execute files from PHP or other
> > programming languages? For example, C, Python, or Perl.
>
> Yeah, that's no big deal.  That's what exec() does.
>
> > I have tried this by putting in
> >
> > exec("http://www.mysite.com/calculate.php";);
>
> Well, "http://www.mysite.com/calculate.php"; is not an executable.  Try
> this instead:
>
> exec("php /calculate.php");

I still don't think this is how exec() should be used when executing remote PHP 
scripts via HTTP, since the web server is not going to give you the underlying 
code simply because you're calling the URL from PHP and not your web browser. 
User-Agent tags do not a secure connection make.

Perhaps doing a wget and directing it to /dev/null (if you're on *nix) would be 
appropriate to invoke a remote script and pass it parameters. Hell, even wget 
to standard output if you want, and use that as your "result code." It's 
basically doing what cURL does, but outside of the PHP script itself.

Anyway, I digress. My point is that exec("php http://mysite.com/script.php";) 
will fail, since it will be reading the remote script's OUTPUT, and not the 
remote script's SOURCE CODE.

   I dont' know how come his code works either. I figured that exec() is not 
going to get me anywhere when I have it stored remotely.
   I am now using cURL instead of using exec(), since it is doing a lot closer 
to what I initiated. I am not sure if I should have a new thread for this, but 
I found that things start to get a little weird when I tried to do cURL with 
Perl files inside. The PHP only brings me back Perl code and not the processed 
content. Is this something I should not be doing with cURL? It seems to do 
quite a bit of powerful processing when I wrote everything in PHP and have it 
stored remotely.

Alice




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



RE: Re: [PHP] exec() Error

2008-06-25 Thread Boyd, Todd M.
> -Original Message-
> From: Per Jessen [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2008 2:48 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] exec() Error
> 
> Wei, Alice J. wrote:
> 
> > I have got a task from my client asking me to build something
> > that allows the variables in the PHP file passed to another
> > PHP file or a file in a different computer language to
> perform
> > some operations on another remote machine. According to my
> > client, he calls this behind the scenes to avoid users screw
> > up the front end, and I am hoping that I can produce one
> > single script, and have it execute some script without the
> > user pushing any button. Has anyone tried using exec()
> > successfully in PHP to execute files from PHP or other
> > programming languages? For example, C, Python, or Perl.
> 
> Yeah, that's no big deal.  That's what exec() does.
> 
> > I have tried this by putting in
> >
> > exec("http://www.mysite.com/calculate.php";);
> 
> Well, "http://www.mysite.com/calculate.php"; is not an executable.  Try
> this instead:
> 
> exec("php /calculate.php");

I still don't think this is how exec() should be used when executing remote PHP 
scripts via HTTP, since the web server is not going to give you the underlying 
code simply because you're calling the URL from PHP and not your web browser. 
User-Agent tags do not a secure connection make.

Perhaps doing a wget and directing it to /dev/null (if you're on *nix) would be 
appropriate to invoke a remote script and pass it parameters. Hell, even wget 
to standard output if you want, and use that as your "result code." It's 
basically doing what cURL does, but outside of the PHP script itself.

Anyway, I digress. My point is that exec("php http://mysite.com/script.php";) 
will fail, since it will be reading the remote script's OUTPUT, and not the 
remote script's SOURCE CODE.

HTH,


Todd Boyd
Web Programmer





RE: [PHP] exec() Error

2008-06-25 Thread Wei, Alice J.
___
From: Per Jessen [EMAIL PROTECTED]
Sent: Wednesday, June 25, 2008 3:47 PM
To: php-general@lists.php.net
Subject: Re: [PHP] exec() Error

Wei, Alice J. wrote:

> I have got a task from my client asking me to build something
> that allows the variables in the PHP file passed to another
> PHP file or a file in a different computer language to perform
> some operations on another remote machine. According to my
> client, he calls this behind the scenes to avoid users screw
> up the front end, and I am hoping that I can produce one
> single script, and have it execute some script without the
> user pushing any button. Has anyone tried using exec()
> successfully in PHP to execute files from PHP or other
> programming languages? For example, C, Python, or Perl.

Yeah, that's no big deal.  That's what exec() does.

> I have tried this by putting in
>
> exec("http://www.mysite.com/calculate.php";);

Well, "http://www.mysite.com/calculate.php"; is not an executable.  Try
this instead:

exec("php /calculate.php");

I just found out that using cURL in my script allows me to call script from 
machine to machine. It turned out perfectly. Thanks to all who have been 
helping me with this!

Alice

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


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



Re: [PHP] exec() Error

2008-06-25 Thread Per Jessen
Wei, Alice J. wrote:

> I have got a task from my client asking me to build something
> that allows the variables in the PHP file passed to another
> PHP file or a file in a different computer language to perform
> some operations on another remote machine. According to my
> client, he calls this behind the scenes to avoid users screw
> up the front end, and I am hoping that I can produce one
> single script, and have it execute some script without the
> user pushing any button. Has anyone tried using exec()
> successfully in PHP to execute files from PHP or other
> programming languages? For example, C, Python, or Perl.

Yeah, that's no big deal.  That's what exec() does. 

> I have tried this by putting in
> 
> exec("http://www.mysite.com/calculate.php";);

Well, "http://www.mysite.com/calculate.php"; is not an executable.  Try
this instead: 

exec("php /calculate.php");


/Per Jessen, Zürich


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



[PHP] exec() Error

2008-06-24 Thread Wei, Alice J.
Hi,

I have got a task from my client asking me to build something that 
allows the variables in the PHP file passed to another PHP file or a file in a 
different computer language to perform some operations on another remote 
machine. According to my client, he calls this behind the scenes to avoid users 
screw up the front end, and I am hoping that I can produce one single script, 
and have it execute some script without the user pushing any button. Has anyone 
tried using exec() successfully in PHP to execute files from PHP or other 
programming languages? For example, C, Python, or Perl.

I have tried this by putting in

  exec("http://www.mysite.com/calculate.php";);

   This is the error I got:

 Warning: exec() [function.exec]: Unable to fork 
[http://www.mysite.com/calculate.php] in C:\Inetpub\wwwroot\read.php on line 31

   I have checked my permissions, and I have set it to 755.
   Does anyone know how I might be able to correct this error?

Thanks in advance.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

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



Re: [PHP] exec return values

2008-04-04 Thread Daniel Brown
On Fri, Apr 4, 2008 at 11:34 AM, Philip Thompson <[EMAIL PROTECTED]> wrote:
> Is there a set list of return values/error codes returned by exec? I am
> running this command on a windows box and getting the following error:
>
>  exec ("net use /delete i: /y", $output, $ret);
>  print_r ($output);// Array()
>  echo "Return: $ret";  // Return: 2

The third parameter ($ret) isn't defined by the exec() function,
but rather by the program called in the first parameter.  I'm not
certain if Windows has a[n easy] way to redirect STDERR to STDOUT, but
if it does, try that.  For example:

&1',$ret,$err);
print_r($ret);
echo "Return: ".$err."\n";
?>

-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



[PHP] exec return values

2008-04-04 Thread Philip Thompson
Is there a set list of return values/error codes returned by exec? I  
am running this command on a windows box and getting the following  
error:


exec ("net use /delete i: /y", $output, $ret);
print_r ($output);// Array()
echo "Return: $ret";  // Return: 2

I tested this statement with the mapped drive (i:) created and without  
it. I get the same result. Now this exec statement is just one  
example, but are there generic return values or is it based solely on  
the command being sent to exec?


I have RTFM (hopefully well enough) and STFW, but have not been  
fruitful in my searches. =/


Thanks,
~Philip

"Personally, most of my web applications do not have to factor 13.7  
billion years of space drift in to the calculations, so PHP's rand  
function has been great for me..." ~S. Johnson



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



Re: [PHP] Php exec

2007-12-31 Thread Richard Lynch
http://php.net/imap_createmailbox

On Sun, December 23, 2007 4:31 pm, mattias wrote:
> If i use courier-mta
> Can i create a php script wich create mailboxes?
> And users
> Hope any understand
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



  1   2   3   4   >