Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default system commands

    i know that system commands can be run using the system("command")
    function, but... some commands, such as mysqldump, require additional
    input - input that can't be entered through the command line...

    (atleast i don't think the password can be entered through the command
    line with mysqldump - i could be wrong...)

    also, is there a way i could have internet explorer, or whatever
    browser, download the output (as opposed to viewing it)?

    thanks in advance :)
    yawnmoth Guest

  2. Similar Questions and Discussions

    1. File system commands
      Hi, I've been trying to work out how to issue file system commands from a PHP script to Redhat Linux. I want to be able to delete files and...
    2. piped system commands
      deb wrote: Try changing the $2 to \$2. Perl is interpolating $2 before it gets to bash, so bash sees "/bin/awk '{print }'". -- Andrew Gaffney...
    3. perl interactive system commands
      rhlinux wrote: I've tried just about every method you can think of to get this to work correctly. Unfortunately, passwd is coded to only accept...
    4. Running system commands
      Hi all, I was wondering, if anyone can help me with running system commands from within php. Actually I have a script which deletes users from my...
    5. System() works on /usr/sbin commands
      hello, i was using system function to invoke useradd command but it doesn't work. well it works for all the commands but not those in /usr/sbin....
  3. #2

    Default Re: system commands

    In article <0k99jvomk7vuucudkjc1pmh7tkt131j5qm@4ax.com>,
    yawnmoth <terra1024@yahoo.com> wrote:
    > also, is there a way i could have internet explorer, or whatever
    > browser, download the output (as opposed to viewing it)?
    Before sending any output, issue this header:

    header('Content-type: application/octet-stream');

    Most browsers will download the file as it's named on the server,
    perhaps prompting the user first to make sure they want to download it.
    If you want to set a different name, send this header as well:

    header('Content-disposition: inline; filename="foobar.txt"');

    hth

    --
    Bulworth : [email]funha@fung.arg[/email] | My email address is ROT13 encoded, decode to mail
    --------------------------|--------------------------------------------------
    <http://www.phplabs.com/> | PHP scripts and thousands of webmaster resources!
    Senator Jay Billington Bulworth Guest

  4. #3

    Default system commands

    i'm running the following php script, and where i would expect it to
    create a file, test.txt, it doesn't. it isn't in the directory i am
    exectuting the script in, nor can i do cat on it (not that i would
    expect to, since it doesn't exist, heh):

    <?php

    print system("ls > test.txt");

    print system("cat ls.txt");

    ?>
    yawnmoth Guest

  5. #4

    Default Re: system commands

    yawnmoth <terra1024@yahoo.com> writes:
    > i'm running the following php script, and where i would expect it to
    > create a file, test.txt, it doesn't. it isn't in the directory i am
    > exectuting the script in, nor can i do cat on it (not that i would
    > expect to, since it doesn't exist, heh):
    >
    > <?php
    >
    > print system("ls > test.txt");
    >
    > print system("cat ls.txt");
    cat test.txt, surely?
    > ?>
    Is safe mode enabled? If so, is there an ls and a cat program in the
    safe_mode_exec_dir?

    --
    Chris
    Chris Morris Guest

  6. #5

    Default Re: system commands

    On 13 Aug 2003 10:16:56 +0100, Chris Morris <c.i.morris@durham.ac.uk>
    wrote:
    >yawnmoth <terra1024@yahoo.com> writes:
    >> i'm running the following php script, and where i would expect it to
    >> create a file, test.txt, it doesn't. it isn't in the directory i am
    >> exectuting the script in, nor can i do cat on it (not that i would
    >> expect to, since it doesn't exist, heh):
    >>
    >> <?php
    >>
    >> print system("ls > test.txt");
    >>
    >> print system("cat ls.txt");
    >
    >cat test.txt, surely?
    hehe - that was the problem :)

    however, that doesn't help me solve the problem i was hoping it would
    solve :(

    if that works, then why doesn't this work?:

    <?php

    system("mysqldump --opt -u $dbuser --password=$dbpasswd $dbname |
    gzip > $dbname" . ".gz");

    print "<a href=\"$dbname" . ".gz\">Download backup</a>";

    ?>

    ls > test.txt outputted to the directory the php script was in (as i
    would expect it to), so why doesn't that? i can't find that file
    anywhere, and when i run the mysqldump command through the command
    line, it works just fine...
    yawnmoth Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139