runCommand()

Tinderbox Icon

The operator, runCommand(), lets rules and actions use the command line.

runCommand(command[,input])

passes command to the C shell. The new process receives input, if any, as its standard input; the process's standard output is returned as the result of calling runCommand.

Example, if a note called "Jane Doe" is dropped on a container with this OnAdd action:

MyResult = runCommand("sendmail -f "+$Email+" "+$Email(parent), "Subject:"+$Name+"\nHello\n.")

This assumes both dropped and container notes have a valid email address in Email. If so, Jane Doe will get an email with subject line "Jane Doe" and body text "Hello"; the email will be from the dropped note's $Email address and to the container's $Email address. User attribute 'MyResult' will receive any message back from standard output.

To use external commands like above you may need to check the encoding of the strings you extract from your TBX attributes. Don't forget to allow for characters like spaces/quotes/apostrophes in attribute values; these will invariably need escaping for safe use in a command line using operators like urlEncode():

MyResult=runCommand("/usr/bin/curl -d 'status="+urlEncode($Name)+"' -u myusername:mypassword http://twitter.com/statuses/update.atom");

In the above, if the value of $Name were "Mark's project", the use of urlEncode() will ensure the string passed to the command line is actually "Mark%27s%20project".

Exactly where you do/don't need to encode attribute values will depend on the syntax of the particular operation you are performing.


Up: Full Operator List
Previous: round(argument)  Next: saturation(color) 

[Last updated: 1 Dec 2008]

Google search aTbRef for:  

Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
[See aTbRef CC licence Attribution/Waiver info info]

Creative Commons License

Made with Tinderbox