is it possible to run python as cgi in cgi-bin ?

Having a problem with your shell account? Post here.

is it possible to run python as cgi in cgi-bin ?

Postby daddy2k on Sat Sep 09, 2006 7:17 pm

Hi there.
I just wanted to execute a python script as a cgi but i failed.
I put it in the cgi-bin folder changed permission with "chmod 777"
and put in the file:

#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-

print "test"

something wrong with it?
Or is it simply not possible to get python to run?
daddy2k
Contributer
Contributer
 
Posts: 32
Joined: Mon Jul 10, 2006 3:14 pm
Location: Germany

Postby Samppa on Sun Sep 10, 2006 10:46 am

I think phoenix doesn't allow programs to be run within the shell.
(\__/)
(='.'=) This is RomMaster's Bunny. Copy and paste bunny into your
(" )_(" ) signature to help him gain world domination.
Samppa
Phoenix Veteran
Phoenix Veteran
 
Posts: 744
Joined: Thu Feb 02, 2006 10:00 am
Location: Finland

Postby daddy2k on Thu Sep 14, 2006 3:23 pm

hm than why is there a cgi-bin?^^
daddy2k
Contributer
Contributer
 
Posts: 32
Joined: Mon Jul 10, 2006 3:14 pm
Location: Germany

Postby Samppa on Fri Sep 15, 2006 1:46 pm

For web apps?
(\__/)
(='.'=) This is RomMaster's Bunny. Copy and paste bunny into your
(" )_(" ) signature to help him gain world domination.
Samppa
Phoenix Veteran
Phoenix Veteran
 
Posts: 744
Joined: Thu Feb 02, 2006 10:00 am
Location: Finland

Postby Tim on Sat Sep 16, 2006 6:29 am

Samppa wrote:I think phoenix doesn't allow programs to be run within the shell.

Then what exactly would you do with it? Rolling Eyes
User avatar
Tim
root
root
 
Posts: 736
Joined: Thu Mar 10, 2005 6:31 am
Location: Australia

Postby Samppa on Sat Sep 16, 2006 7:23 am

Hm.
I could have sworn there was a problem with this on irc some time.
(\__/)
(='.'=) This is RomMaster's Bunny. Copy and paste bunny into your
(" )_(" ) signature to help him gain world domination.
Samppa
Phoenix Veteran
Phoenix Veteran
 
Posts: 744
Joined: Thu Feb 02, 2006 10:00 am
Location: Finland

Postby De Kus on Sat Sep 16, 2006 7:51 am

I believe Tim is taking about the general "running programs within the shell issue" and not "running programs out of cgi-bin via Webserver". Usually this folder is mainly used for perl scripts, first check if these are avaible. Maybe you can also checkout the apache/php configuration to see if it is even enabled at all. I mean, you might be still able to run your python script out of a php script.
Image
User avatar
De Kus
Phoenix Veteran
Phoenix Veteran
 
Posts: 305
Joined: Mon Mar 14, 2005 2:15 pm
Location: Germany

Postby slashfoo on Sat Sep 16, 2006 11:18 pm

@All, my experience tells me, that if you have a normal configuration of cgi-bin, and you can run perl scripts in cgi-bin, then you can most probably run python scripts and even c programs in there, note the 'shebang' points to perl?

Code: Select all
#!/bin/perl -w


That is precisely what tells you what program is going to be used to parse that cgi... if it is a python script then you only need to put the first line pointing to python, and put python codes on the rest of the lines Smile

Just my 1c.
Slashfoo
"Hello my friend, stay a while and listen..."
--- Deckard Cain (Diablo game)
slashfoo
Contributer
Contributer
 
Posts: 70
Joined: Tue Sep 05, 2006 12:44 pm

Postby De Kus on Sun Sep 17, 2006 10:54 am

@slashfoo
have you tried this one?
Code: Select all
env python script.py
python: can't open file 'script.py'
Image
User avatar
De Kus
Phoenix Veteran
Phoenix Veteran
 
Posts: 305
Joined: Mon Mar 14, 2005 2:15 pm
Location: Germany

Postby slashfoo on Mon Sep 18, 2006 12:52 pm

Oh, I am sorry, I do not have a shell account, it was just a comment about 'former life' experience if you want to call it that.

Although, I thought you were speaking of somepythonprogram.cgi (since .cgi's are not necessarily perl scripts) and the parser of the script (if needed) is defined by the first line of the script (shebang or hashbang).

Check out these links.

This should work with any .cgi file with execution rights (chmod +x file.cgi), try it.
http://www.python.net/crew/davem/cgifaq ... 02.001.htp

This one explains how to put .py scripts to be executed with python
http://www.python.net/crew/davem/cgifaq ... 01.001.htp
Slashfoo
"Hello my friend, stay a while and listen..."
--- Deckard Cain (Diablo game)
slashfoo
Contributer
Contributer
 
Posts: 70
Joined: Tue Sep 05, 2006 12:44 pm


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron