Search code examples
linuxrundeck

Problem of running command from Rundeck (Linux)


On a linux server I am running following command with any error and getting the result.

xxxxx@server1 ~]$ grep -o  "\-w.*%" /etc/sysconfig/nrpe-disk 
-w 15% -c 7%
[xxxxx@server1 ~]$ 

I want to run same command from Rundeck's command line interface with same xxx user which has sudo rights too.

Command executed from rundeck gives option '.' invalide error:

option invalide -- '.'
Utilisation : grep [OPTION]... MOTIF [FICHIER].

I tried many times with different ways such as escaping . sign, running it with sudo, with absolute path, double quotes - single quotes etc. Still I am receiving same output however, in the server command works locally. What's the way to fix it ?


Solution

  • You can do that putting that on an inline-script ("Script" step) or call an external script with the command content ("Script file or URL" step).

    Another way is to use cat tool to print the file and capture the output using log filter (Click on the tiny Gear icon at the left of the step > Click on "Add Log Filter" > Select "Key/value data" and in pattern use with this regex: .*(-w .*%).*, put a name of the data - eg: diskdata - and click on "Log data" checkbox) and you get the output that you want, you can print that value using echo ${data.diskdata} in next step. Check.