cgi-bin / html icmp ping specified address
cgi-bin / html icmp ping specified address
(OP)
i have done a large amount of googling but must have the search fileds wrong or there is no info on my question "unlightly"
i want a basic webpage that has a text box that i input an ip address or hostname and the server goes off pings the address then displays the results in the browser.
i can bash script a fixed ip in cgi-bin but the bit i can't work out is passing the textbox input across to the script
S1 being the ip or alike
is anyone able to show me this or point me to a simple guide.
i want a basic webpage that has a text box that i input an ip address or hostname and the server goes off pings the address then displays the results in the browser.
i can bash script a fixed ip in cgi-bin but the bit i can't work out is passing the textbox input across to the script
S1 being the ip or alike
is anyone able to show me this or point me to a simple guide.
RE: cgi-bin / html icmp ping specified address
Feherke.
http://free.rootshell.be/~feherke/
RE: cgi-bin / html icmp ping specified address
3.00.15(1)
RE: cgi-bin / html icmp ping specified address
Pity. Bash 4 has associative arrays, which would be useful here. As far as I remember, I used this for Bash 3.
CODE --> HTML ( fragment )
<input type="text" name="host">
<input type="submit" value="Ping !">
</font>
CODE --> Bash
[[ "$QUERY_STRING" ]] && {
while IFS='=' read -d '&' key val; do
key="${key//%??/_}"
val="${val//+/ }"
val="$( eval echo -e "${val//%/\\\\x}" )"
eval "GET_$key[\${#GET_$key[*]}]=\"$val\""
done <<< "${QUERY_STRING//;/&}&"
}
[[ "$GET_host" ]] && ping -c 10 -w 10 -W 10 "$GET_host"
If you want to add more form elements, for example to let specify the count of packets to send, just add <input type="text" name="count"> to the HTML and change [[ "$GET_host" ]] && ping -c "${GET_count:-10}" -w 10 -W 10 "$GET_host" in the script.
Note that you should test the $GET_* variables' value before using them.
As I remember, I found no security flow with that way to set the $GET_* variables, but do some tests your self. ( Enter `date`, $(date), echo $HOME and alike int form, then see if they appear in the output exactly, or they were executed/substituted. )
Feherke.
http://free.rootshell.be/~feherke/
RE: cgi-bin / html icmp ping specified address
The server encountered an internal error or misconfiguration and was unable to complete your request.
i have checked the permissions of the ping.sh
-rwsr-xr-x 1 root root
what would be causing this issue ?
RE: cgi-bin / html icmp ping specified address
t headers: ping.sh, referer: http://svr-mrtg-1/cgi-snmp.html
RE: cgi-bin / html icmp ping specified address
i now seem to be gettng the error bash: ping: permission denied, this is permissions to run the ping command.
i need to and some form of permission ?
RE: cgi-bin / html icmp ping specified address
Oops. Sorry, I forgot to output the HTTP header before the content.
Regarding the permission, it is really strange. I am not expert in permission problems, so I have no idea for now.
Anyway I would take a look at the user who's permission is using your web server. ( In case of Apache it is specified with the User directive in httpd.conf . ) Then I would try to become that user and run ping from the console.
Feherke.
http://free.rootshell.be/~feherke/
RE: cgi-bin / html icmp ping specified address
RE: cgi-bin / html icmp ping specified address
Sure. Just I understood that you solved it.
I added only the highlighted line, the rest is working to me :
CODE
[[ "$QUERY_STRING" ]] && {
while IFS='=' read -d '&' key val; do
key="${key//%??/_}"
val="${val//+/ }"
val="$( eval echo -e "${val//%/\\\\x}" )"
eval "GET_$key[\${#GET_$key[*]}]=\"$val\""
done <<< "${QUERY_STRING//;/&}&"
}
echo $'Content-type: text/plain\n'
[[ "$GET_host" ]] && ping -c 10 -w 10 -W 10 "$GET_host"
Feherke.
http://free.rootshell.be/~feherke/
RE: cgi-bin / html icmp ping specified address
-rwxrwxrwx 1 apache root 1939 May 20 12:59 /var/www/cgi-bin/iso
[root@svr-cache-1 /]#
/var/log/httpd/error_log shows the following
[Fri May 21 13:55:08 2010] [error] [client 172.30.137.41] bash: iso: Permission
denied
how do i give apache permission to execute the bash file called iso ?
RE: cgi-bin / html icmp ping specified address
Sorry, no idea. I never needed more than that.
Feherke.
http://free.rootshell.be/~feherke/
RE: cgi-bin / html icmp ping specified address