Results 1 to 3 of 3

Thread: Can I use PHP's shell_exec on my VPS 200?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Jun 2007
    Posts
    4

    Default Can I use PHP's shell_exec on my VPS 200?

    I can successfully gunzip a file using my SSH connection but when I try to do this via PHP code (I need this run on a CRON job) nothing happens (and my file doesn't get unzipped).

    $cmd = "gunzip /var/www/vhosts/myservername/httpdocs/test.txt.gz'";
    $output = exec("$cmd");

    If this is a PHP coding error then I'd gladly troubleshoot it but can anyone confirm that using this should work on a VPS 200?

    I also have a need to unzip TAR files and put its contents into a separate folder via PHP code. Without the exec command I have no idea how to do this.

    Regards,

    Darryl

  2. #2
    Member Newbie
    Join Date
    Oct 2006
    Posts
    90

    Default

    The Spry vps accounts do have php installed, and it can be used from the command line, so in theory you should be able to use it as a scripting language.

    That said, as most all non-web scripts are either shell or perl scripts you'll have trouble finding much guidance online. You will have to use the shebang notation (#!), and still enclose all the commands in the usual '<? ?>', but you should be able to use php scripts on the command line.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2007
    Posts
    4

    Default

    From the php.net site concerning exec():

    Note: When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir. For practical reasons it is currently not allowed to have .. components in the path to the executable.

    This might be your issue. HTH,

    -dan

    EDIT: I tried to post a link for ya but the forum says "You are only allowed to post URLs to other sites after you have made 15 posts or more.". <rolling eyes> Whatever.

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
  •