我试图使用python脚本在linux上通过tabcmd访问tableau。
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:
为什么子进程不能识别与手动运行相同的打印方式?
这就是windows和linux之间的区别。
process = subprocess.check_output(cmdCommand, shell=True, stderr=subprocess.STDOUT
我在shell上加了true,在linux上就完美了