我是 Python 新手,在这个论坛上已经找到了很好的提示,看起来很棒,非常感谢!
现在我正在为一个问题而苦苦挣扎,并且已经尝试了几件事但没有成功。 也许你可以帮助我?
#Create Private Key
strServerFileKey = strBackupPathKS + strOSTypePathSep + strPrivateKey
print("strServerFileKey is: " + strServerFileKey)
#openSSLArgs = " genrsa -out " + strServerFileKey + " " + str(intKeySize)
openSSLArgs = " genrsa -out " + strServerFileKey + " " + str(intKeySize)
print("OpenSSLArgs are " + openSSLArgs)
if os.name == 'posix':
strComKey = strOpenSSLPath + openSSLArgs
print("Path is " + strComKey)
else:
strComKey = "\"" + strOpenSSLPath + "\"" + openSSLArgs
#strComKey = "\"" + strOpenSSLPath + "\"" + openSSLArgs
#strComKey = strOpenSSLPath + "\"" + openSSLArgs
subprocess.run(strComKey )
重要的是部分
if os.name == 'posix':
因为在这种情况下它是一个 Linux 服务器和部分
subprocess.run(strComKey )
如果我运行这部分代码,我会收到以下失败消息:
文件“/usr/lib64/python3.6/subprocess.py”,第1364行,在_execute_child 引发 child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] 没有那个文件或目录: '/app/sim/tsim/pw/apache/bin/openssl genrsa -out /app/sim/SSL_Certificate/AutoCertCreate/ss008783.key 3072': '/app/sim /tsim/pw/apache/bin/openssl genrsa -out /app/sim/SSL_Certificate/AutoCertCreate/ss008783.key 3072'
如果我手动运行给出错误消息的那部分,它就完美了:
/app/sim/tsim/pw/apache/bin/openssl genrsa -out /app/sim/SSL_Certificate/AutoCertCreate/ss008783.key 3072
知道问题在哪里吗? 如果您需要更多信息,请告诉我,它是 Python 3.6
非常感谢,祝您有美好的一天并保持安全
干杯
马库斯