Ask a questionAsk a question
 

AnswerCalling RRDTool from script

  • Saturday, November 07, 2009 4:10 PMLindeborg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi All!

    I'm trying to call RRDTool from a powershell script but doesn't work as expected:

    I've got four integers named $Count $Abort $Active $Commit

    The syntax to add values into the round robin db of RRDTool with four values is: rrdtool update N:value1:value2:value3:value4

    I call rrdtool as this: & rrdtool update N:$Count:$Abort:$Active:$Commit

    rrdtool thinks it gets the argument: N:$Commit as if & rrdtool update N:$Commit

    I've tried all kind of different combinations of ', " ,`,´ to get it right...

    Please, what is wrong?

Answers

  • Saturday, November 07, 2009 4:55 PMMarco ShawMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Can you be more specific with what the variables contain?

    If might help to try it like this:
    PS>& rrdtool update N:${count}:${abort}:${active}:${commit}

    If you're still stuck, I can maybe try it later this week.

All Replies

  • Saturday, November 07, 2009 4:55 PMMarco ShawMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Can you be more specific with what the variables contain?

    If might help to try it like this:
    PS>& rrdtool update N:${count}:${abort}:${active}:${commit}

    If you're still stuck, I can maybe try it later this week.
  • Saturday, November 07, 2009 5:16 PMLindeborg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Great, that worked.
    So what's the business with the {}'s?
  • Sunday, November 08, 2009 1:32 PMMarco ShawMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It basically allows you to properly delimit your variable names.

    If you simply say $foo:$bar, the PowerShell parser doesn't see this as variables $foo and $bar, it doesn't know whether the ":" is meant to be part of the variable name or not.