小编der*_*ris的帖子

使用带有特殊字符的 xargs

我有以下问题。得到一个文件,其中包含 FS 的某些路径/文件。出于某种原因,这些确实包括整个范围的特殊字符,如空格、单/双引号,甚至有时是 Copyright ASCII。

我需要运行文件的每一行并将其传递给另一个命令。

到目前为止我尝试过的是:

<input_file xargs -I % command %
Run Code Online (Sandbox Code Playgroud)

在我从 xargs 收到这条消息之前一直在工作

xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
Run Code Online (Sandbox Code Playgroud)

但是 usinf 这个选项对我来说根本不起作用

xargs: argument line too long
Run Code Online (Sandbox Code Playgroud)

有没有人有一个解决方案可以处理特殊字符。不必与 xargs 一起使用,但我需要按原样将行传递给命令。

提前谢谢了。

linux bash xargs

4
推荐指数
1
解决办法
2852
查看次数

多处理只能加入已启动的进程

我有以下Python代码

jobs = []
p = Process(target=self.verify_process, args=(vm_ha1, creds, run_cmd_ha1, ip_ha1))
jobs.append(p)
p.start()
p = Process(target=self.verify_process, args=(vm_ha2, creds, run_cmd_ha2, ip_ha2))
jobs.append(p)
p.start
p = Process(target=self.verify_process, args=(vm_client, creds, run_cmd_client, ip_client))
jobs.append(p)
p.start
for p in jobs:
    p.join()
Run Code Online (Sandbox Code Playgroud)

如果VM上的进程已完成,则目标是一个小的def检查,并将打印退出代码.

当它运行时,我在第一个进程完成后得到一个错误,并写出它的输出

  File "/usr/lib/python2.7/multiprocessing/process.py", line 144, in join
    assert self._popen is not None, 'can only join a started process'
AssertionError: can only join a started process
Run Code Online (Sandbox Code Playgroud)

当我四处寻找时,我发现了一些这样的提及.其中大多数是因为他们都在使用p.run()并且应该使用p.start().

但我已经在使用p.start()了.

这是我第一次捆绑Multiprocessing,所以我可能会错误地使用它.

从我所看到的,应该开始所有3个过程.

python multiprocessing

1
推荐指数
1
解决办法
1964
查看次数

标签 统计

bash ×1

linux ×1

multiprocessing ×1

python ×1

xargs ×1