【发布时间】:2020-05-06 01:29:04
【问题描述】:
我正在尝试使用 python 脚本通过 linux 机器上的 tabcmd 访问画面:
tabcmd= "login -s " + taburl + " -u " + tabuser+ " --password-file " + '"' + tabpwpath + '"' + " --no-certcheck" #specify your cmd command
print(tabcmd)
cmdCommand = tabcmd_path + tabcmd
print("check " + cmdCommand)
process= subprocess.check_output(cmdCommand,stderr=subprocess.STDOUT)
被传递的 cmdCommand 是这样构造的:
/opt/tableau/tabcmd/bin/tabcmd login -s http://tableau.server.com -u username --password-file "/home/user/testpw.file" --no-certcheck
当我在 linux 中手动运行这个命令时它可以工作,但是当使用子进程时它会给出如下错误:
process= subprocess.check_output([cmdCommand],stderr=subprocess.STDOUT)
File "/home/ec2-user/.pyenv/versions/3.7.0/lib/python3.7/subprocess.py", line 376, in check_output
**kwargs).stdout
File "/home/ec2-user/.pyenv/versions/3.7.0/lib/python3.7/subprocess.py", line 453, in run
with Popen(*popenargs, **kwargs) as process:
File "/home/ec2-user/.pyenv/versions/3.7.0/lib/python3.7/subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "/home/ec2-user/.pyenv/versions/3.7.0/lib/python3.7/subprocess.py", line 1499, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory:
为什么子进程无法识别与手动运行完全相同的打印方式相同的方式?
【问题讨论】:
标签: python-3.x linux tableau-api