php-general Digest 27 Aug 2013 06:45:12 -0000 Issue 8346

Topics (messages 321971 through 321985):

Re: exec and system do not work
        321971 by: Jim Giner
        321973 by: marco.behnke.biz
        321976 by: Tamara Temple
        321978 by: Ethan Rosenberg, PhD
        321979 by: Tim Streater
        321980 by: David Robley
        321981 by: Ethan Rosenberg, PhD
        321982 by: Jasper Kips
        321983 by: David Robley

How to send "post"-variables in a "Location" header
        321972 by: Ajay Garg
        321974 by: marco.behnke.biz
        321975 by: Matijn Woudt
        321977 by: Tamara Temple

Permissions
        321984 by: Ethan Rosenberg, PhD
        321985 by: David Robley

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
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 'file2<br />';
    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<br />';
    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<br />';
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.
--- End Message ---
--- Begin Message ---

> 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.

--- End Message ---
--- Begin Message ---
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 'file2<br />';
>>>>    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<br />';
>>>>    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<br />';
> 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
> 


--- End Message ---
--- Begin Message ---

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 'file2<br />';
    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<br />';
    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<br />';
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


--- End Message ---
--- Begin Message ---
On 26 Aug 2013 at 22:01, PhD Ethan Rosenberg <erosenb...@hygeiabiomedical.com> 
wrote: 

>>> if( !file_exists("/var/www/orders.txt"));

                                            ^
                                            |
What's the semicolon doing there -----------+

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

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

See above.

--
Cheers  --  Tim

--- End Message ---
--- Begin Message ---
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 'file2<br />';
>>>>     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<br />';
>>>>     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<br />';
> 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 'file2<br />';
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.


--- End Message ---
--- Begin Message ---


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 'file2<br />';
     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<br />';
     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<br />';
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 'file2<br />';
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

--- End Message ---
--- Begin Message ---
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 'file2<br />';
>>>>>>     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<br />';
>>>>>>     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<br />';
>>> 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 'file2<br />';
>> 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
> 


--- End Message ---
--- Begin Message ---
"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 'file2<br />';
>>>>>>      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<br />';
>>>>>>      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<br />';
>>> 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 'file2<br />';
>> 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.


--- End Message ---
--- Begin Message ---
Hi all.

I have a scenario, wherein I need to do something like this ::

###############################################################
        $original_url = "/autologin.php";
        $username = "ajay";
        $password = "garg";

        header('Location: ' . $original_url);
###############################################################

As can be seen, I wish to redirect to the URL "autologin.php".

Additionally, I wish to pass two POST key-value pairs :: "user=ajay" and
"password=garg" (I understand that passing GET key-value pairs is trivial).

Is it  even possible?
If yes, I will be grateful if someone could let me know how to redirect to
a URL, passing the POST key-value pairs as necessary.


Looking forward to a reply :)


-- 
Regards,
Ajay

--- End Message ---
--- Begin Message ---

> Ajay Garg <ajaygargn...@gmail.com> hat am 26. August 2013 um 21:48
> geschrieben:
>
>
> Hi all.
>
> I have a scenario, wherein I need to do something like this ::
>
> ###############################################################
>         $original_url = "/autologin.php";
>         $username = "ajay";
>         $password = "garg";
>
>         header('Location: ' . $original_url);
> ###############################################################
>
> As can be seen, I wish to redirect to the URL "autologin.php".
>
> Additionally, I wish to pass two POST key-value pairs :: "user=ajay" and
> "password=garg" (I understand that passing GET key-value pairs is trivial).
>
> Is it  even possible?
> If yes, I will be grateful if someone could let me know how to redirect to
> a URL, passing the POST key-value pairs as necessary.

Iirc it is not possible to pass post body content via location redirect.
What you can do: Set auth headers

http://forums.phpfreaks.com/topic/84480-solved-how-to-send-authorization-basic-header/

>
>
> Looking forward to a reply :)
>
>
> --
> Regards,
> Ajay

--
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

--- End Message ---
--- Begin Message ---
On Mon, Aug 26, 2013 at 9:48 PM, Ajay Garg <ajaygargn...@gmail.com> wrote:

> Hi all.
>
> I have a scenario, wherein I need to do something like this ::
>
> ###############################################################
>         $original_url = "/autologin.php";
>         $username = "ajay";
>         $password = "garg";
>
>         header('Location: ' . $original_url);
> ###############################################################
>
> As can be seen, I wish to redirect to the URL "autologin.php".
>
> Additionally, I wish to pass two POST key-value pairs :: "user=ajay" and
> "password=garg" (I understand that passing GET key-value pairs is trivial).
>
> Is it  even possible?
> If yes, I will be grateful if someone could let me know how to redirect to
> a URL, passing the POST key-value pairs as necessary.
>
>
> Looking forward to a reply :)
>
>
Usually you would pass this around in sessions. If you must however use
post, you can only do so with using some javascript magic. Write a form
with hidden input and auto submit it.

- Matijn

--- End Message ---
--- Begin Message ---
On Aug 26, 2013, at 2:48 PM, Ajay Garg <ajaygargn...@gmail.com> wrote:
> Hi all.
> 
> I have a scenario, wherein I need to do something like this ::
> 
> ###############################################################
>        $original_url = "/autologin.php";
>        $username = "ajay";
>        $password = "garg";
> 
>        header('Location: ' . $original_url);
> ###############################################################
> 
> As can be seen, I wish to redirect to the URL "autologin.php".
> 
> Additionally, I wish to pass two POST key-value pairs :: "user=ajay" and
> "password=garg" (I understand that passing GET key-value pairs is trivial).
> 
> Is it  even possible?
> If yes, I will be grateful if someone could let me know how to redirect to
> a URL, passing the POST key-value pairs as necessary.
> 
> 
> Looking forward to a reply :)

Since this seems that it will not work, I'm wondering if you could take a step 
back for us and say what is it you're hoping to accomplish by this. Maybe 
there's a better way to get you what you need that is possible, and also will 
be good PHP. Describe your scenario in higher level terms, not how you'd 
implement it, but what the outcome you need is, and what the design goal is for 
the user.


--- End Message ---
--- Begin Message ---
Dear List -

Tried to run the program, that we have been discussing, and received a 403 error.

rosenberg:/var/www# ls -la StoreInventory.php
-rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php

rosenberg:/var# ls -ld www
drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www

I had set the S bit [probably a nasty mistake] and I thought I was able to remove the bit. [it doesn't show above]

How do I extricate myself from the hole into which I have planted myself?

TIA

Ethan




--- End Message ---
--- Begin Message ---
Ethan Rosenberg wrote:

> Dear List -
> 
> Tried to run the program, that we have been discussing, and received a
> 403 error.
> 
> rosenberg:/var/www# ls -la StoreInventory.php
> -rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php
> 
> rosenberg:/var# ls -ld www
> drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www
> 
> I had set the S bit [probably a nasty mistake] and I thought I was able
> to remove the bit. [it doesn't show above]
> 
> How do I extricate myself from the hole into which I have planted myself?
> 
> TIA
> 
> Ethan

This is in no way a php question, as the same result will happen no matter 
what you ask apache to serve from that directory.

You have the directory permissions set to 776 not 777.
-- 
Cheers
David Robley

Steal this tagline and I'll tie-dye your cat!


--- End Message ---

Reply via email to