Professional Web Applications Themes

passthru loses php posted variables - PHP Development

Anyone come across something like this before? I have made a little test script as follows: <? header ("Content-Type: application/pdf"); $command_line = "/usr/bin/pdflabelseries " . escapeshellcmd($_POST['labelstart']) . " " . escapeshellcmd($_POST['labelend']); exec ("echo \"$command_line\" >/opt/specs/labels.txt"); //passthru($command_line); ?> The form takes input from a posted form with two variables, labelstart and labelend. In the above test, if I put in 'start' and 'end' as the posted variable data, the output from /opt/specs/labels.txt (writable by the http server) is: /usr/bin/pdflabelseries start end All is well and good. Now is where it heads South. I uncomment the passthru command above. The output from ...

  1. #1

    Default passthru loses php posted variables

    Anyone come across something like this before?

    I have made a little test script as follows:
    <?
    header ("Content-Type: application/pdf");
    $command_line = "/usr/bin/pdflabelseries " .
    escapeshellcmd($_POST['labelstart']) . " " .
    escapeshellcmd($_POST['labelend']);
    exec ("echo \"$command_line\" >/opt/specs/labels.txt");
    //passthru($command_line);
    ?>

    The form takes input from a posted form with two variables, labelstart and
    labelend. In the above test, if I put in 'start' and 'end' as the posted
    variable data, the output from /opt/specs/labels.txt (writable by the http
    server) is:
    /usr/bin/pdflabelseries start end
    All is well and good. Now is where it heads South. I uncomment the
    passthru command above. The output from the script in /opt/specs/labels.txt
    from the same posted form with the same data entered is now:
    /usr/bin/pdflabelseries
    pdflabelseries is a C program that I have confirmed works perfectly on the
    command line (i.e. generates the requisite pdf file to stdout).
    Even if the C program fails (which it does not appear to do from the output
    in the httpd logs as it outputs its command line to stderr), surely php
    should not lose its own internal variables, especially, for a command that
    is executed BEFORE the passthru command.

    I am truly baffled.

    Any help appreciated.
    Regards

    Mark

    I am running vanilla Mandrake 9.1 with the following PHP rpms:
    libphp_common430-430-11mdk
    php-pear-4.3.0-3mdk
    apache2-mod_php-2.0.44_4.3.1-2mdk
    php-xml-4.3.0-2mdk
    php-dba_bundle-4.3.0-4mdk
    php-pgsql-4.3.0-4mdk
    php-xmlrpc-4.3.0-2mdk
    php-manual-en-4.3.0-2mdk
    php430-devel-430-11mdk
    php-gd-4.3.0-2mdk
    Exasperated Guest

  2. #2

    Default Re: passthru causes php to lose internal variables

    system() has the same problem as passthru. Thanks for the suggestion
    anyway.

    I wonder if I should post this to the bug list?

    "Nicole" <430ntr3kaeontrek.com> wrote in message
    news:20030915090814.47764.qmailpb1.pair.com...
    > Hi,
    >
    > Did you try using the system() command instead and skip using exec and
    > passthru?
    >
    > --
    > Nicole
    >
    >
    > "Exasperated" <phpinstruform.com> wrote in message
    > news:20030914202252.32486.qmailpb1.pair.com...
    > > Anyone come across something like this before?
    > >
    > > I have made a little test script as follows:
    > > <?
    > > header ("Content-Type: application/pdf");
    > > $command_line = "/usr/bin/pdflabelseries " .
    > > escapeshellcmd($_POST['labelstart']) . " " .
    > > escapeshellcmd($_POST['labelend']);
    > > exec ("echo \"$command_line\" >/opt/specs/labels.txt");
    > > //passthru($command_line);
    > > ?>
    > >
    > > The form takes input from a posted form with two variables, labelstart
    and
    > > labelend. In the above test, if I put in 'start' and 'end' as the
    posted
    > > variable data, the output from /opt/specs/labels.txt (writable by the
    http
    > > server) is:
    > > /usr/bin/pdflabelseries start end
    > > All is well and good. Now is where it heads South. I uncomment the
    > > passthru command above. The output from the script in
    > /opt/specs/labels.txt
    > > from the same posted form with the same data entered is now:
    > > /usr/bin/pdflabelseries
    > > pdflabelseries is a C program that I have confirmed works perfectly on
    the
    > > command line (i.e. generates the requisite pdf file to stdout).
    > > Even if the C program fails (which it does not appear to do from the
    > output
    > > in the httpd logs as it outputs its command line to stderr), surely php
    > > should not lose its own internal variables, especially, for a command
    that
    > > is executed BEFORE the passthru command.
    > >
    > > I am truly baffled.
    > >
    > > Any help appreciated.
    > > Regards
    > >
    > > Mark
    > >
    > > I am running vanilla Mandrake 9.1 with the following PHP rpms:
    > > libphp_common430-430-11mdk
    > > php-pear-4.3.0-3mdk
    > > apache2-mod_php-2.0.44_4.3.1-2mdk
    > > php-xml-4.3.0-2mdk
    > > php-dba_bundle-4.3.0-4mdk
    > > php-pgsql-4.3.0-4mdk
    > > php-xmlrpc-4.3.0-2mdk
    > > php-manual-en-4.3.0-2mdk
    > > php430-devel-430-11mdk
    > > php-gd-4.3.0-2mdk
    Exasperated Guest

Similar Threads

  1. [SOLVED] Session loses all variables during Response.Redirect
    By Mark MacRae in forum ASP.NET General
    Replies: 2
    Last Post: November 26th, 06:58 PM
  2. iterate through POSTed variables
    By Ike in forum PHP Development
    Replies: 8
    Last Post: August 12th, 09:10 PM
  3. Server.Transfer loses posted values only v1.1
    By Cowboy \(Gregory A. Beamer\) in forum ASP.NET General
    Replies: 0
    Last Post: July 24th, 04:19 PM
  4. Server.Transfer loses posted values
    By Gary Varga in forum ASP.NET General
    Replies: 0
    Last Post: July 22nd, 07:43 AM
  5. Session loses all variables during Response.Redirect
    By Natty Gur in forum ASP.NET General
    Replies: 2
    Last Post: July 21st, 12:33 PM

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
  •  

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