I'm trying to redirect the contents of command output to a file in a CGI program. The issue for me is that the output file is not getting created.
The CGI Code snippet is as follows:
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html>"
echo "<body>"
`mysql -u root -predhat -H -D mysql -e "select host,db from db;" > output.txt`
echo "</body>"
echo "</html>"
The CGI script is getting called from an HTML program. Also,I can use INTO OUTFILE
with a mysql
command, but I want that output redirection should work for any command.
Ownerships are as follows:
#ls -l /var/www/cgi-bin/example.sh
-rwxr-xr-x 1 root root 839 Apr 11 21:34 /var/www/cgi-bin/example.sh
# ps -ef | grep httpd
root 2442 1 0 19:30 ? 00:00:00 /usr/sbin/httpd
apache 2464 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd
apache 2465 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd
apache 2466 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd
apache 2467 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd
apache 2468 2442 0 19:30 ? 00:00:00 /usr/sbin/httpd
How can I resolve the issue?