Невозможно напечатать стандартный вывод внешнего скрипта на Python3 + CGI.
/ var / www / html / index.html:
<html>
<body>
<form name="Form" method="POST" action="/cgi-bin/top2.py">
<input type="text" name="input">
<input type="submit" value"OK" name="button">
</form>
</body>
</html>
/ var / www / cgi-bin/top2.py:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import cgi
import subprocess
import cgitb
cgitb.enable()
print("Content-Type: text/html; charset=UTF-8\n")
print("<html><body>")
form=cgi.FieldStorage()
input=form["input"].value
print("input: {}".format(input))
print(type(input))
p=subprocess.run("/var/www/cgi-bin/get_id_or_name/get_id_or_name.sh -n {}".format(input).split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
str=p.stdout.decode("utf8")
str=str.rstrip("\n")
print("out: {}".format(str))
print("</body></html>")
Вывод браузера:
input: 12345 out: