Ask Your Question

how can I use apostrophe in a command statment (within exec)

asked 2015-03-25 04:56:39 -0600

stefan_bormann gravatar image

updated 2015-03-25 10:40:09 -0600

csharpsteen gravatar image

the problem is shown here a part of a init.pp file

exec{ "join_domain":
command => "/opt/pbis/bin/domainjoin-cli setname `hostname`",
command => "/opt/pbis/bin/domainjoin-cli join --notimesync --ou "OU=Servers,OU=BLP,OU=Admin,DC=ISTINT,DC=NET" <domain admin username>",

command => "/opt/pbis/bin/config LoginShellTemplate /bin/bash",
command => "/opt/pbis/bin/config AssumeDefaultDomain true",
command => "/opt/pbis/bin/config RequireMembershipOf istint\\ar_blp_linux_user",
command => "/opt/pbis/bin/config SyncSystemTime false",

the second command statment have "OU=Servers,OU=BLP,OU=Admin,DC=ISTINT,DC=NET" as a parameter and it comes with apostrohes

any suggestions how to mask these?

Thanks -Stefan

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-03-25 11:20:15 -0600

WhatsARanjit gravatar image

If you're not using an puppet variables in your command, you can single quote the entire thing. Then using double quotes is not problem inside.

command => 'some command "args=value"'

If you must use double quotes inside double quotes (or single inside single), then use backslash to escape them.

command => 'some command \'args=value\''
edit flag offensive delete link more

answered 2015-03-31 05:17:13 -0600

stefan_bormann gravatar image

Works. Thanks you!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-03-25 04:56:39 -0600

Seen: 1,831 times

Last updated: Mar 31 '15