Find the answer to your Linux question:
Results 1 to 6 of 6
PHP Code: <? exec ( "./zipalign -v 4 update.zip update4.zip" ); ?> this script wont work on my server for some reason can anyone see whats wrong with it? i want it to run ...
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    16

    php script wont execute

    PHP Code:
    <?
    exec
    ("./zipalign -v 4 update.zip update4.zip");
    ?>
    this script wont work on my server for some reason
    can anyone see whats wrong with it?
    i want it to run that file and its in the right folder with the right permissions.

  2. #2
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    1,939
    Have you tried full tags? Change <? to <?php.

  3. #3
    Just Joined!
    Join Date
    May 2010
    Posts
    16
    yea and its turned on so it should accept <? also
    anyways fixed
    function exe($cmd){
    $aret=array();
    if(!$f=popen($cmd,'r')){return null;}
    while(!feof($f)){
    $o=fgets($f,1024);
    $aret[]=$o;
    }
    pclose($f);
    return $aret;
    }

    $a=exe('./zipalign -v 4 update.zip update4.zip');
    foreach($a as $e){
    print $e."<br />";
    }
    used that script
    fixed it

  4. #4
    Linux Newbie
    Join Date
    Apr 2010
    Location
    Novosibirsk, Russia
    Posts
    136
    see phpinfo() - maybe exec() is restricted? Switch on 'display_errors' - it will help you to understand the reason of error :

    Code:
    <?php
    ini_set(‘error_reporting’, E_ALL);
    ini_set(‘display_errors’, ‘On’);
    /*
    Your code ...
    */
    ?>

  5. #5
    Just Joined!
    Join Date
    May 2004
    Location
    CO USA
    Posts
    5
    I'd guess permissions since its exec and often webserver can't do that.

  6. #6
    Just Joined!
    Join Date
    Aug 2005
    Posts
    5
    propably you need to change the directory to where the `zipalign` executable resides in your file system.

    Code:
    <?php
    chdir('/absolute/path/to/my/executable/');
    exec("./zipalign -v 4 update.zip update4.zip");
    ?>
    Also my advice is to always redirect the STDERR of your commands, like:

    Code:
    <?php
    chdir('/absolute/path/to/my/executable/');
    exec("./zipalign -v 4 update.zip update4.zip 2>&1");
    ?>

Posting Permissions

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