Basic cgi-script in a mini-hosting account

Web hosting discussion, programming, and shared and dedicated servers.
3 posts Page 1 of 1
by trevorld » Sat Mar 09, 2013 9:39 pm
Hello,

I'm trying to run a basic script in my personal sonic.net mini-hosting account.

I've uploaded basic python, perl, and php scripts to my WWW_pages/trevorld directory of the form:

#!/usr/bin/python

print "Content-Type: text/html"
print "<html><body>Hello World!</body></html>"

And then I sent the file to be executable using my FTP program (so overall permissions 755). When I go to trevorld.user.sonic.net/test.py (or .pl or .php) I see the source code but the script itself doesn't run. What am I doing wrong? https://wiki.sonic.net/wiki/CGI_FAQ_List suggests that I should just need to put a script into my WWW_pages directory and give it the right permissions and it should run. What am I doing wrong?

Thanks,

Trevor
by joemuller » Mon Mar 11, 2013 12:58 pm
By default, the web server treats python and perl scripts as text files, regardless of permissions. You can enable CGI functionality in your web directory by adding a small .htaccess file like this:

Code: Select all

AddHandler cgi-script .cgi .pl .py
As long as your scripts send output the browser can understand, everything should work. :D
I'm a proud employee of Sonic.net! :-)
by trevorld » Tue Mar 12, 2013 9:03 pm
Thanks Joe! That did the trick. Maybe you could edit the CGI wiki to reflect this?

https://wiki.sonic.net/wiki/CGI_FAQ_List

I tried logging in to the wiki with my username and password to do it myself but it wouldn't let me...
3 posts Page 1 of 1

Who is online

In total there are 23 users online :: 1 registered, 0 hidden and 22 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: Google [Bot] and 22 guests