Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 使用Python子流程调用SOLR post工具命令_Python 3.x_Solr_Subprocess - Fatal编程技术网

Python 3.x 使用Python子流程调用SOLR post工具命令

Python 3.x 使用Python子流程调用SOLR post工具命令,python-3.x,solr,subprocess,Python 3.x,Solr,Subprocess,我想通过Python子流程调用此SOLR post命令: /u01/tony/solr-7.5.0/bin/post -c techproducts /u01/tony/data/bbc/politics/*.txt -params "literal.keywords=politics" 我尝试使用python子流程模块启动此模块,如下所示: subprocess.run(["/u01/tony/solr-7.5.0/bin/post -c techproducts /u01/tony/dat

我想通过Python子流程调用此SOLR post命令:

/u01/tony/solr-7.5.0/bin/post -c techproducts /u01/tony/data/bbc/politics/*.txt -params "literal.keywords=politics"
我尝试使用python子流程模块启动此模块,如下所示:

subprocess.run(["/u01/tony/solr-7.5.0/bin/post -c techproducts /u01/tony/data/bbc/politics/*.txt -params", "literal.keywords=politics"], stdout=PIPE, stderr=PIPE)
但这会引发以下错误:

FileNotFoundError: [Errno 2] No such file or directory: '/u01/tony/solr-7.5.0/bin/post -c techproducts /u01/tony/data/bbc/politics/*.txt -params': '/u01/tony/solr-7.5.0/bin/post -c techproducts /u01/tony/data/bbc/politics/*.txt -params'

您需要拆分所有参数-第一个参数是要运行的命令

["/u01/tony/solr-7.5.0/bin/post", "-c", "techproducts", "/u01/tony/data/bbc/politics/*.txt", "-params", "literal.keywords=politics"
另外,请注意,
*.txt
扩展是由您的shell完成的,因此,如果命令没有在shell上下文中调用(…这里没有),它将不会被扩展。但是,由于
bin/post
工具接受目录作为直接参数,并且具有
-filetypes
参数,因此可以使用

"-filetypes txt", "/u01/tony/data/bbc/politics/"
。。相反

bin/post
工具也是一个shell脚本,因此,如果它不允许直接调用(我不确定如何解决这个问题),您可能必须使用

"/usr/bin/env", "bash"

还有。

您需要拆分所有参数-第一个参数是要运行的命令

["/u01/tony/solr-7.5.0/bin/post", "-c", "techproducts", "/u01/tony/data/bbc/politics/*.txt", "-params", "literal.keywords=politics"
另外,请注意,
*.txt
扩展是由您的shell完成的,因此,如果命令没有在shell上下文中调用(…这里没有),它将不会被扩展。但是,由于
bin/post
工具接受目录作为直接参数,并且具有
-filetypes
参数,因此可以使用

"-filetypes txt", "/u01/tony/data/bbc/politics/"
。。相反

bin/post
工具也是一个shell脚本,因此,如果它不允许直接调用(我不确定如何解决这个问题),您可能必须使用

"/usr/bin/env", "bash"

还有。

错误说明了什么?错误说明了什么?