On StackO: "pass variable cli on linux to web page"



  • @user1772519 said:

    I have a web server on linux using apache with php support, I
    have a client machine that have open in a browser an specific web page
    from the server, the page is refreshing every second because its shows
    and email address when postfix receive and email

    this is the code of the file mounted in the server called mish.php

    <?php
    $mail=NULL
    if ($mail == NULL) 
        goto end
    else
        echo $mail;
    end:
        echo."awaiting mail";
    ?>

    However I do not understand how to pass the $mail variable to this page. Currently I am editing the file via a sed script:

    sed -i '2s/.*/$mail="ocelas@hotmail.com";/' /var/www/emergencia/mish.php

    and in consecuence the page shows now the email as desired.

    I am aware that using sed to do this is a kludge but do not understand PHP/LAMP architecture enough to pass the variable in the right way - can this be done with bash, php cli, perl, via $_GET, etc.? What would be the proper practice?

    I'm glad user1772519 is aware of what a kludge it is to use sed to edit the PHP file. But the way the if was constructed? Tsc, tsc...

    [Link]

    </div>


  • heh - you realise that's after a few edits - stack overflow is a collaborative wiki... I invite you especially to look at the first edit - [the revision log]


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.