简体   繁体   English

如何从解析内部命令中逃避单引号?

[英]How to escape single quote from parsing inside command?

I have to start the command at the bottom as a specific user in a script. 我必须在脚本中作为特定用户在底部启动命令。 the parameter $vmargs needs to be in single quotes ('$vmargs'). 参数$ vmargs需要用单引号('$ vmargs')。 im stuck here because its always parsed. 我被困在这里因为它总是被解析。 the vmargs parameter has some java options within. vmargs参数中有一些java选项。

 su synesty -c "screen -dmS appscreen ./eclipse -vmargs 
                -DAPP_ENV=$automatey_note  $vmargs"

Hope anyone can help. 希望有人可以提供帮助

Update: Sorry I saw my question was not clear. 更新:对不起我看到我的问题不明确。 The parameter have to be solved. 必须解决该参数。

 '-DencryptorCredentials=currentPass|oldPass|1 -Xms512m -Xmx2048m 
 -DLOGGING_HOME=configuration/ -Djava.io.tmpdir=/tmp -Dorg.osgi.service.http.port=8081
 -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Xdebug         
 -Xnoagent
 -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n 
 -Djava.net.preferIPv4Stack=true -DapplyDbMigrations=true -XX:MaxPermSize=128m     
 -XX:-HeapDumpOnOutOfMemoryError '

Thats the stuff and I need the single quotes, otherwise shell will not recognize it as parameters 多数民众赞成,我需要单引号,否则shell不会将其识别为参数

Just put single quotes around $vmargs . 只需在$vmargs附近加上单引号。 It will still be expanded because the whole thing is in double-quotes. 它仍然会被扩展,因为整个事情都是双引号。

su synesty -c "screen -dmS appscreen ./eclipse -vmargs -DAPP_ENV=$automatey_note '$vmargs'"

如果你想将$vmargs su synesty传递给su synesty不变,“逃避”将保留字符串的美元: -

su synesty -c "screen -dmS appscreen ./eclipse -vmargs -DAPP_ENV=$automatey_note \\$vmargs"

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

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