Using awk in a rundeck command?

909 views
Skip to first unread message

Dan Tootill

unread,
Feb 8, 2017, 12:04:02 PM2/8/17
to rundeck-discuss
Hi,

I'm struggling to get Rundeck to run awk commands on a remote node, even something as basic as printing the first column from a text file e.g. running this over SSH:

# ssh myhost "awk '{print \$1}' /etc/hosts"


This works fine from the command line, but when I create a Rundeck command to do the same, it fails:

awk: syntax error near line 1
15:41:51awk: illegal statement near line 1
15:41:52Remote command failed with exit status 2
15:41:52Failed: NonZeroResultCode: Remote command failed with exit status 2


I have tried escaping the single quotes and not escaping the dollar sign, nothing seems to work. Any help would be much appreciated.


Thanks,

Dam

Alex Honor

unread,
Feb 8, 2017, 12:10:04 PM2/8/17
to rundeck...@googlegroups.com
Hi Dam,

The command string quoting is a bit cumbersome. That said, try this command string:

awk '"{print $1}"' /etc/hosts

It would be nice to have an option to control how quoting works to be more intuitive.

Thanks

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/8fb3e83b-07da-4703-8338-c4b1f14bcfeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Alex Honor

[Rundeck | a...@rundeck.com ]

Dan Tootill

unread,
Feb 15, 2017, 9:59:12 AM2/15/17
to rundeck-discuss
Hi Alex,

Cheers for getting back to me. That succeeded but the output wasn't right; it returned the whole file rather than just the first column.

However, escaping the $ sign therein did work:

awk '"{print \$1}"' /etc/hosts


Many thanks!


On Wednesday, 8 February 2017 17:10:04 UTC, Alex Honor wrote:
Hi Dam,

The command string quoting is a bit cumbersome. That said, try this command string:

awk '"{print $1}"' /etc/hosts

It would be nice to have an option to control how quoting works to be more intuitive.

Thanks
On Wed, Feb 8, 2017 at 7:49 AM, Dan Tootill <danto...@gmail.com> wrote:
Hi,

I'm struggling to get Rundeck to run awk commands on a remote node, even something as basic as printing the first column from a text file e.g. running this over SSH:

# ssh myhost "awk '{print \$1}' /etc/hosts"


This works fine from the command line, but when I create a Rundeck command to do the same, it fails:

awk: syntax error near line 1
15:41:51awk: illegal statement near line 1
15:41:52Remote command failed with exit status 2
15:41:52Failed: NonZeroResultCode: Remote command failed with exit status 2


I have tried escaping the single quotes and not escaping the dollar sign, nothing seems to work. Any help would be much appreciated.


Thanks,

Dam

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discu...@googlegroups.com.



--

Alex Honor

[Rundeck | a....@rundeck.com ]

Reply all
Reply to author
Forward
0 new messages