Re: [PHP] exec and system do not work
[email protected] ("Ethan Rosenberg, PhD")
| Newsgroups | php.general |
|---|---|
| Organization | Hygeia Biomedical Research, Inc. |
| Message-ID | <[email protected]> |
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, [email protected] wrote: >>> >>> >>>> Tamara Temple <[email protected]> hat am 26. August 2013 um 08:33 >>>> geschrieben: >>>> >>>> >>>> >>>> On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg >>>> <[email protected]> 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: [email protected] >>> >>> 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