我有一个hello_world.py脚本,它接受用户名和密码并打印用户信息。python单独执行,没有任何错误。但是,当我从HTML提交时,HTML页面会给出内部服务器500错误。我已经在httpd.conf的文件系统中为脚本添加了可执行权限,但是,我不确定为什么在我提供submit时不执行这个命令。

谢谢你的建议和帮助。

IP Address:

Password:

我的python脚本是#!/usr/bin/python

# Import modules for CGI handling

import cgi, cgitb

import getpass

import sys

import telnetlib

# Create instance of FieldStorage

form = cgi.FieldStorage()

# Get data from fields

user_name = form.getvalue('user_name')

//username will get IP of machine

pass_word = form.getvalue('pass_word')

loginid = 'admin'

tc = telnetlib.Telnet(user_name)

tc.read_until("login: ")

tc.write(loginid + "\n")

tc.read_until("Password: ")

tc.write(pass_word + "\r\n")

tc.write("ls -l\n")

tc.write("exit\n")

print "Content-type:text/html\r\n\r\n"

print ""

print "

"

print "

Hello "

print ""

print "

"

print "

%s is IP and %s is passowrd

" % (user_name, pass_word)

print tc.read_all()

print ""

print ""

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐