Calling bash script from html

Discussion in 'Apache' started by winchester169, Apr 12, 2010.

  1. #1
    I am trying to call the following script from my HTML page and have tried a miriad of ways to do so from php to perl/cgi to javascript and nothing is working. Please help
    I want an alert when someone accesses my page and I want to use netcat for the alert. I have nc working with my aasterisk server fin but I want to use the apache as well.

    The script is alerter and is located in the /usr/local/bin tree and contains the following

    ==========================================================
    #!/bin/bash
    /bin/echo -n -e "New Visitor" | /usr/bin/nc -w 1 x.x.x.213 10629
    ==========================================================

    The script runs fine from the command line but how do I call it from an html page (or php even)

    thank you
     
    winchester169, Apr 12, 2010 IP
  2. coffear

    coffear Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #2
    There is no proper way to do this in HTML however within PHP try putting the path of the bash file within tics (`) or alternatively use the shell_exec() function to call the bash file. This may however be disabled in PHP. Some admins remove this functionality due to the potential security implications.
     
    coffear, Apr 13, 2010 IP