0

I am using a CentOS VM from Backspace with LAMP installed. I have a python script I want to run from the CGI-BIN. I have browsed to the path on my browser and I get an 500 server error. Assured, this is the first time I ever used CentOS and python but I understand pretty well. but this has really got me. I get this error :

[Tue Nov 04 12:46:07 2014] [error] [client 86.2.110.133] (8)Exec format error: exec of '/var/www/cgi-bin/payment-test.cgi' failed
[Tue Nov 04 12:46:07 2014] [error] [client 86.2.110.133] Premature end of script headers: payment-test.cgi

Here is my script :

import sys
import json
import cgi
import cgitb
import stripe

#2
cgitb.enable()

print 'Content-Type: text/json'
print

#3
stripe.api_key = ''
#4
json_data = sys.stdin.read()
json_dict = json.loads(json_data)

#5
stripeAmount = json_dict['stripeAmount']
stripeCurrency = json_dict['stripeCurrency']
stripeToken = json_dict['stripeToken']
stripeDescription = json_dict['stripeDescription']

#6
json_response = stripe.Charge.create(amount=stripeAmount, currency=stripeCurrency, card=stripeToken, description=stripeDescription)

print json_response

Is it because there is no header pointing to my Python files ? If so where are they ? Please help I am so lost.

thanks

Jason
  • 1,037
  • 3
  • 13
  • 30

1 Answers1

0

You need a hashbang line at the top.

#!/usr/bin/env python

import sys
import json
import cgi
...
Community
  • 1
  • 1
John Kugelman
  • 307,513
  • 65
  • 473
  • 519