如何在 systemd 命令行参数中使用空格? [英] How can I use spaces in systemd command line arguments?

查看:41
本文介绍了如何在 systemd 命令行参数中使用空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 systemd 单元,参数中有空格

I have a systemd unit with spaces in an argument

ExecStart=command --argument="text text"

systemd 似乎无法识别双引号或单引号,并将参数拆分为两个参数.知道如何防止这种情况吗?我在 CoreOS 中使用 systemd v218.

It seems that systemd does not recognize the double or single quotes and it splits up the argument into two arguments. Any idea how I can prevent that? I am using systemd v218 within CoreOS.

推荐答案

不幸的是,这实际上很难做到.我从 this answer 中窃取了此信息.唯一的方法是将您的参数放在一个环境文件中,然后将它们用作变量(如在/etc/.progconfig 中):

This is actually surprisingly difficult to do, unfortunately. I stole this info from this answer. The only way to do it is to put your arguments in an environment file and then use them as variables as such (like in /etc/.progconfig):

ARG1=text
ARG2=text

然后在运行命令之前导入环境文件:

Then import the environment file before running your command:

EnvironmentFile=/etc/.progconf
ExecStart = command $ARG1 $ARG2

这篇关于如何在 systemd 命令行参数中使用空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆