Menu

program with if do not give results

Help
2008-09-04
2013-04-16
  • prowlerxpla

    prowlerxpla - 2008-09-04

    I'm trying to change an icon on my superkaramba theme depending on the result of an if statement,
    the example is this:

    text x=100 y=60 sensor=program program="var1=`acpi -b | awk -F', ' '{print $2}' | cut -b 1-3` & if [ "$var1" = 100 ]; then echo "giusti" ; else echo "sbagliato"; fi" interval=10000

    but this do not give any result, if i give the command in a console:
    var1=`acpi -b | awk -F', ' '{print $2}' | cut -b 1-3` & if [ "$var1" = 100 ]; then echo "giusti" ; else echo "sbagliato"; fi
    the result is given, "giusti" if $var1=100 and "sbagliato" if $var1 <> 100.

    Why in superkaramba the result is not given? have you any suggestion?
    many thanks for any answer
    pierluigi

     
    • Orcan Ogetbil

      Orcan Ogetbil - 2008-09-04

      I think it is because of the quotation marks (")

      Try replacing the "s with 's or \&quot;s inside the program=""

      i.e.

      program="var1=`acpi -b | awk -F', ' '{print $2}' | cut -b 1-3` & if [ '$var1' = 100 ]; then echo 'giusti' ; else echo 'sbagliato'; fi"
      or something like this...
      Orcan

       
    • prowlerxpla

      prowlerxpla - 2008-09-05

      Thank you very much, the first problem is solved, it run ok in this way:
      program="var1=`acpi -b | awk -F', ' '{print $2}' | cut -b 1-3` & if [ '$var1' = 100 ]; then echo 'giusti' ; else echo 'sbagliato'; fi"
      but if I want to show $var1 it doesn't show, for example

      program="var1=`acpi -b | awk -F', ' '{print $2}' | cut -b 1-3` & if [ '$var1' = 100 ]; then echo 'Batteria carica' ; else echo $var1; fi"

      if $var1=100 is ok it shows "Batteria carica" but else it shows:
      $var1(not the value but the string $var1)  if I write     else echo '$var1'; fi
      anything if I write     else echo $var1; fi
      anything if I write     else echo \&quot;$var1\&quot;; fi

       

Log in to post a comment.