I'm a newbie in linux administration and I'm running a web server with cgi, and in the bellow script, I want to do SIGHUP to x PID, but from the html when I fullfill the PID number and I press on the "STOP BUTTON" that correspond to my first if condition, it doesn't kill the PID. Pasting the same line "sudo kill -1 PID" directly in the console, I can kill it.
> #!/bin/bash
LOG_FILE="/usr/lib/cgi-bin/user.log"
arr=(${QUERY_STRING//[=&]/ })
opcion=${arr[1]}
NombreProceso=${arr[3]}
Fecha=$(date)
echo "-Procesos-" >> user.log
echo "$opcion" >> user.log
echo "$NombreProceso" >> user.log
if [ $opcion = 1 ];
then
sudo kill -1 $NombreProceso
echo "$Fecha::Paramos el proceso $NombreProceso" >> user.log
echo "$opcion" >> user.log
fi
if [ $opcion = 2 ];
then
sudo kill -19 $NombreProceso
echo "$Fecha::Pausamos el proceso $NombreProceso" >> user.log
echo "$opcion" >> user.log
fi
echo Content-Type: text/html
echo -e "
<html>
<head>
<title> UOLS WEB Unai Ayoub Jaime</title>
</head>
<body>"
echo -e "<textarea style='width:100%;height:90%; resize: none' disabled>"
ps -aux | less
echo -e "</textarea>"
echo -e "
</body>
</html>
"