【问题标题】:python subprocess with tableau tabcmd error带有tableau tabcmd错误的python子进程
【发布时间】: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


    【解决方案1】:

    windows和linux的区别:

    process = subprocess.check_output(cmdCommand, shell=True, stderr=subprocess.STDOUT
    

    我添加了 shell tr​​ue 并且在 linux 中它可以完美运行

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-12
      • 1970-01-01
      • 1970-01-01
      • 2014-06-09
      • 1970-01-01
      • 2016-06-17
      • 2015-04-16
      • 2010-11-25
      相关资源
      最近更新 更多