Ad Widget

Collapse

Oddities with awk and system.run

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wdingus
    Junior Member
    • Dec 2007
    • 7

    #1

    Oddities with awk and system.run

    I was trying to add an item to store the installation date of our Linux servers and ran into some odd behaviour with awk and system.run[] in testing. Looks like I can get the desired results with cut but would still be curious why it fails with awk. Thoughts?

    Code:
    [root@vigilance ~]# zabbix_get -sserver -ksystem.run["(sudo stat -c %z /root/install.log 2>/dev/null || echo 'unknown') | cut -d' ' -f1"]
    2010-06-10
    
    [root@vigilance ~]# zabbix_get -sserver -ksystem.run["(sudo stat -c %z /root/fake 2>/dev/null || echo 'unknown') | cut -d' ' -f1"]
    unknown
    
    [root@vigilance ~]# zabbix_get -sserver -ksystem.run["(sudo stat -c %z /root/install.log 2>/dev/null || echo 'unknown') | awk '{print $1}'"]
    2010-06-10 02:49:31.000000000 -0500
    
    [root@vigilance ~]# zabbix_get -sserver -ksystem.run["(sudo stat -c %z /root/fake 2>/dev/null || echo 'unknown') | awk '{print $1}'"]
    unknown
    Last edited by wdingus; 04-08-2011, 16:44. Reason: oops, wrong quote characters, entire thing double quoted, needed singles inside
Working...