SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    UK
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    shell_exec with windows/*nix systems?

    PHP Code:
     $do shell_exec("mysql -u$dbusername -p$dbpassword $dbname < $backupfilepath"); 
    Would that work on *nix machines and Windows machines? I can't try as I haven't anything set up on the internet, but I've tested that command on my windows computer (winXP) with a chdir command before it to change to the bin dir in mysql folder, and that execution works, but on the net, would that work on a server?

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i would use exec() instead of shell_exec() just because it's possible that exec() could work in safe mode.

    anyway, it should work (as long as you can exec() stuff etc.) on any server, as long as 1) /path/to/mysql/bin/ is in the path or 2) if you first chdir() to /path/to/mysql/bin/ or you specify that full path in the exec().
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    UK
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So on any server, I should definitely have a chdir before the exec line, and I should use the exec function instead of shell_exec...

    Doesn't sound too hard if that's the right way to do it .

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    right, a chdir() or use the full path to the mysql, mysqldump, etc. command; although most *nix servers would probably work without it since /path/to/mysql/bin/ is usually in the path.


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
  •