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 tamouse.li...@gmail.com hat am 26. August 2013 um
08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, 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);


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 'file2br /';
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 'file2br /';
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 'file2br /';
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 DIDNT 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-27 Thread Daniel Brown
On Sun, Aug 25, 2013 at 11:41 PM, 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 'file2br /';
echo file_exists(/var/www/orders.txt);
 }

?php echo `whoami`; ?

-- 
/Daniel P. Brown
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-26 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 'file2br /';
 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 'file2br /';
 echo file_exists(/var/www/orders.txt);
}

Ethan


Hi Ethan,

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

?php

$path = '/var/www/orders.txt';
if( !file_exists( $path ) )
{
if( !touch( $path ) )
{
echo 'Failed to touch file into existence: '.$path.\n;
}
else
{
if( !chmod( $path, 0766 ) )
{
echo 'Failed to update file permissions: '.$path.\n;
}
}
}

?

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-26 Thread Tamara Temple

On Aug 25, 2013, at 10:41 PM, 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 'file2br /';
   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 'file2br /';
   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-26 Thread ma...@behnke.biz


 Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
 geschrieben:



 On Aug 25, 2013, at 10:41 PM, 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);

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 'file2br /';
    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 'file2br /';
    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-26 Thread Ethan Rosenberg


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




Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, 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);


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 'file2br /';
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 'file2br /';
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 'file2br /';
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 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 tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, 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);


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 'file2br /';
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 'file2br /';
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 'file2br /';
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 DIDNT 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 ma...@behnke.biz


 Ethan Rosenberg erosenb...@hygeiabiomedical.com 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 Tamara Temple

On Aug 26, 2013, at 1:41 PM, Ethan Rosenberg erosenb...@hygeiabiomedical.com 
wrote:
 On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:
 Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
 geschrieben:
 
 
 
 On Aug 25, 2013, at 10:41 PM, 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);
 
 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 'file2br /';
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 'file2br /';
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 'file2br /';
 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 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 tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, 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);


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 'file2br /';
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 'file2br /';
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 'file2br /';
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 DIDNT 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 David Robley
Ethan Rosenberg wrote:

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


 Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
 geschrieben:



 On Aug 25, 2013, at 10:41 PM, 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);

 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 'file2br /';
 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 'file2br /';
 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 'file2br /';
 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.'br /';
  system(chmod 766 /var/www/orders.txt, $ret2);
  echo 'chmod returned ' .$ret2.'br /';
  echo 'file2br /';
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



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 tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, 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);


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 'file2br /';
 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 'file2br /';
 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 'file2br /';
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.'br /';
   system(chmod 766 /var/www/orders.txt, $ret2);
   echo 'chmod returned ' .$ret2.'br /';
   echo 'file2br /';
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 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 
erosenb...@hygeiabiomedical.com 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 tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
 geschrieben:
 
 
 
 On Aug 25, 2013, at 10:41 PM, 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);
 
 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 'file2br /';
 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 'file2br /';
 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 'file2br /';
 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.'br /';
   system(chmod 766 /var/www/orders.txt, $ret2);
   echo 'chmod returned ' .$ret2.'br /';
   echo 'file2br /';
 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
 


--
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 tamouse.li...@gmail.com hat am 26. August 2013 um
 08:33 geschrieben:



 On Aug 25, 2013, at 10:41 PM, 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);

 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 'file2br /';
  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 'file2br /';
  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 'file2br /';
 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.'br /';
system(chmod 766 /var/www/orders.txt, $ret2);
echo 'chmod returned ' .$ret2.'br /';
echo 'file2br /';
 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-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 'file2br /';
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 'file2br /';
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