my first simple cgi bash file
source link: https://www.codesd.com/item/my-first-simple-cgi-bash-file.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
my first simple cgi bash file
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 :-(
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.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK