简体   繁体   English

将临时libc与一个工具结合使用,该工具是另一个工具的参数

[英]Using an ad-hoc libc with a tool which is an argument of another tool

I need to use a particular libc to run a tool (cp). 我需要使用特定的libc来运行工具(cp)。 The problem is that this tool has to be used as argument of another tool (for example timeout) and I don't want to use the modified libc with this one. 问题在于该工具必须用作另一种工具的参数(例如超时),而我不想与此工具一起使用修改后的libc。

I tried to do: 我试着做:

timeout 10 LD_LIBRARY_PATH=/path/to/mod/libc/ cp a b

But I received the error: 但是我收到了错误:

timeout: failed to run command 'LD_LIBRARY_PATH=/path/to/mod/libc/': No such file or directory

And, as I said, I can't do: 而且,正如我所说,我做不到:

LD_LIBRARY_PATH=/path/to/mod/libc/ timeout 10 cp a b

as timeout would use the modified libc. 因为超时将使用修改后的libc。 Is there any way to do this? 有什么办法吗?

You can achieve that by using the env utility: 您可以使用env实用程序来实现:

timeout 10 /usr/bin/env LD_LIBRARY_PATH=/path/to/mod/libc/ cp a b

Env will set the environment variable and exec the other utility with that environment. Env将设置环境变量,并在该环境中执行其他实用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM