Execute a BASH one liner but stuck on NXLog syntax

Tags:

#1 casey1234

Hi, I'm trying to execute the following bash command using NXLog's im_exec input module:
/usr/sbin/route -n | grep 'UG[ \t]' | awk '{print $2}'
From the Linux terminal that command will give the local gateway.

When I attempt to run the command in NXLog I get the following:

2020-01-24 13:43:09 WARNING im_exec process /usr/sbin/route exited
2020-01-24 13:43:10 ERROR subprocess '8114' returned a non-zero exit value of 3

Input module I'm using to execute the command:

<Input Bash>
   Module  im_exec
                Restart true
                Command /usr/sbin/route
              Arg -n | grep 'UG[ \t]' | awk '{print $2}'
              Arg grep 'UG[ \t]'
              Arg awk '{print $2}'
              Arg sleep 30
        <Exec>
       $gateway = $raw_event;
    </Exec>
</Input>

I've tried various combinations of configuring the Arg's but so far no luck.
If I try putting everything in the Command field I get this error:
/usr/sbin/route -n |grep 'UG[ \t]'| awk '{print $2}';sleep 30;No such file or directory

Can someone help me with the correct syntax?

NOTE: It seems like the problem is with using the | character in the command. Anyone know if NXLog will accept this argument or what syntax I need to use?

Thanks in advance!!

#2 b0ti Nxlog ✓
#1 casey1234
Hi, I'm trying to execute the following bash command using NXLog's im_exec input module: /usr/sbin/route -n | grep 'UG[ \t]' | awk '{print $2}' From the Linux terminal that command will give the local gateway. When I attempt to run the command in NXLog I get the following: 2020-01-24 13:43:09 WARNING im_exec process /usr/sbin/route exited 2020-01-24 13:43:10 ERROR subprocess '8114' returned a non-zero exit value of 3 Input module I'm using to execute the command: <Input Bash> Module im_exec Restart true Command /usr/sbin/route Arg -n | grep 'UG[ \t]' | awk '{print $2}' Arg grep 'UG[ \t]' Arg awk '{print $2}' Arg sleep 30 <Exec> $gateway = $raw_event; </Exec> </Input> I've tried various combinations of configuring the Arg's but so far no luck. If I try putting everything in the Command field I get this error: /usr/sbin/route -n |grep 'UG[ \t]'| awk '{print $2}';sleep 30;No such file or directory Can someone help me with the correct syntax? NOTE: It seems like the problem is with using the | character in the command. Anyone know if NXLog will accept this argument or what syntax I need to use? Thanks in advance!!

The above is a shell command while im_exec can not evaluate shell commands. You'll need to run all that via bash -c.