You should use your browser's file associations to use your editor for downloaded .gp files. It is a web server, not a browser, who uses cgi-scripts.
my first simple cgi bash file
Domanda
I use my internet browser to display images/graphs I created with gnuplot
. So for each picture I have a plot.gp
file that contains gnuplot
commands. My final goal is to open an editor with the file plot.gp
when I click on the picture.
The only way I found to achieve this is to use cgi
to run a bash scripts. But I'm not able to make an "hello word" code work... So here is what I did :
- I installed on linux the packaged cgi-mapserver
- I saved in the file
hello.bash
in/usr/lib/cgi-bin/
and gave it the correct permission (chmod 755 /usr/lib/cgi-bin/hello.bash)
.
But when I do firefox /usr/lib/cgi-bin/hello.bash
my browser display the whole file instead of only "hello world!"
My file /usr/lib/cgi-bin/hello.bash
:
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Welcome</title></head>"
echo "<body>"
echo "Hello world"
echo "</body></html>"
I'm sure I forget something very basic... but I can't figure what it is :-(
Soluzione
Altri suggerimenti
Browser cannot run the shell script and show it's output. You can store shell script's output in a temp HTML file and open it like thisL
bash /usr/lib/cgi-bin/hello.bash > /tmp/hello.html
And then open it in firefox:
firefox file:///tmp/hello.html
I know this is in reply to a very old help request. But makbe it will help someone.
Provided that your server supports cgi and you moved the hello.bash script to the directory of cgi-bin. And then changed permissions to at least 644 and and owner ship of root:users. It will run as posted.
Doing this in LAMPP, from the browser I enter http://localhost/cgi-bin/hello.bash and I can see "Hello world"