pass a command output as another command's parameter

48 views
Skip to first unread message

cheniour ghassen

unread,
May 26, 2014, 9:09:43 AM5/26/14
to puppet...@googlegroups.com
Hi everyone,
In some place of my puppet script i need to direct the output of a command as an argument to another one.
the commands are
exec { 'create-endpoint':
command => "id = $( /usr/bin/keystone --os-token=admin  --os-endpoint=http://master:35357/v2.0  service-list  | /bin/grep glance | awk '{print $2}' ) ; /usr/bin/keystone                                                      --os-token=$admin_token --os-endpoint=admin endpoint-create --publicurl=$var --internalurl=$var --adminurl=$var --service-id=$id",
}
but puppet seems to not understand $2.
this is the best solution i have realized. I am really stuck here for a while now.
Any help would be appreciated.
Thanks for your help.
Sincerely,
Ghassen Cheniour.

Dirk Heinrichs

unread,
May 26, 2014, 9:15:11 AM5/26/14
to puppet...@googlegroups.com
Am 26.05.2014 15:09, schrieb cheniour ghassen:

but puppet seems to not understand $2.

Because it's an awk variable. You need to escape it somehow (\$2, maybe).

HTH...

    Dirk
--

Dirk Heinrichs, Senior Systems Engineer, Engineering Solutions
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Tel: +49 2226 1596666 (Ansage) 1149
Email: d...@recommind.com
Skype: dirk.heinrichs.recommind
www.recommind.com

cheniour ghassen

unread,
May 26, 2014, 9:18:28 AM5/26/14
to puppet...@googlegroups.com
Hi Dirk,
i tried to escape but this doesn't work .
thanks


--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/H6KH0v5ra0c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/53833E5D.8060503%40recommind.com.

For more options, visit https://groups.google.com/d/optout.

Dirk Heinrichs

unread,
May 26, 2014, 9:24:48 AM5/26/14
to puppet...@googlegroups.com
Am 26.05.2014 15:18, schrieb cheniour ghassen:

i tried to escape but this doesn't work .

Hmm, try awk \'...\', like shown here.

Bye...

Dirk Heinrichs

unread,
May 26, 2014, 9:31:01 AM5/26/14
to puppet...@googlegroups.com
Am 26.05.2014 15:24, schrieb Dirk Heinrichs:
Am 26.05.2014 15:18, schrieb cheniour ghassen:

i tried to escape but this doesn't work .

Hmm, try awk \'...\', like shown here.

There's another solution here, which suggests to escape the subshell call (id = \$(...) in your case).

And, you can always put all the commands into an external script and call that.

cheniour ghassen

unread,
May 26, 2014, 10:09:28 AM5/26/14
to puppet...@googlegroups.com
Hi Dirk,
This is a quite a good idea (to escape using ' rather than ").
I will try it.
Thanks a lot.
Sincerely,
Ghassen Cheinour.


--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/H6KH0v5ra0c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages