SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy exec() function in windows

    First off, I'm running a windows 2003 vps server and part of my script uses this command:

    Code:
    exec ('' . 'c:\\PHP\\ . ' -c ' . 'C:\\PHP\\php.ini' . ' ' . $mname .' ' . $file_id . ' ' . ' 2>>C:\\output.txt &');
    on linux, this command with the correct php paths and a dev\null rather than c:\output.txt works. however in windows it does not.

    in the output.txt file, i get this message
    Code:
    'C:\PHP\' is not recognized as an internal or external command,
    operable program or batch file.
    PHP is located in c:\PHP and I've tried giving cmd.exe IUSER permissions, yet it still wont work. any suggestions?

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i assume c:\\PHP is a directory and not a program? where is t executable now? Also >> doesn't work on windows.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2006
    Location
    Wigan, Lancashire. UK
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginethis View Post
    Also >> doesn't work on windows.
    It always used to, although not necessarily in the same way as on Linux:
    Code:
    c:\php\php.exe -f helloWorld.php > outfile.txt
    should redirect the output of the helloWorld.php script to a new file called outfile.txt, creating one if it doesn't exist, and overwriting any existing outfile.txt

    Code:
    c:\php\php.exe -f helloWorld.php >> outfile.txt
    should redirect the output of the helloWorld.php script to a new file called outfile.txt, creating one if it doesn't exist, and appending to any existing outfile.txt
    ---
    Development Projects:
    PHPExcel
    PHPPowerPoint

  4. #4
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,397
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    I do not know if it has any effect in this case but when I use exec with ImageMagick I need to use " not '
    Only for windows, the ' works ok for unix


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •