Simply creating an expression which references an object's attribute(s) is enough to make the connection happen.
Use the 'expression' command to create an expression from a script. You can make the content of the expression a variable first, as you've done here, or you can just do it all in one line. For example: expression -s "polyCube1.translateY = sin(time);";...will work, and you should get the same result with: string $exp = "polyCube1.translateY = sin(time);";
expression -s $exp;Hope that helps.