e.g., to run a script (drag the script to your widget 'Files' section):
widget.system("./myscript.sh", null);Simple write to file 'data.txt'"
widget.system("/bin/echo Some data >> data.txt", null);Simple file read from 'data.txt':
widget.system("/bin/echo More data >> data.txt", null);
var data =Run a java application:
widget.system("/bin/cat data.txt ", null).outputString;
widget.system("/usr/bin/javaNote the use of the path to the executable in the system call. Looks like the widget doesn't have a good path variable set up in it's shell. Not sure why, but it's easy enough to find an executable location by typing 'which java' in Terminal.", null)
Make sure that the widget has the attribute 'Allow Command Line Access' turned on or instead you'll get a non obvious exception when executing the system call.
4 comments:
People should read this.
How can I use "echo" to read the HOME environment variable?
Looks like env is what you need:
"/usr/bin/env"
will fetch all environment variables.
To only show a particular env variable pass the result to grep. e.g. for the DISPLAY enviroment variable:
"/usr/bin/env | /usr/bin/grep ^DISPLAY"
The ^ character ensures that DISPLAY is matched at the start of a line.
I suppose you could also use the ~ character as this is interpreted as the users home directory.
e.g.
Change directory to the curernt users home:
cd ~
or change directory to a specific users home:
cd ~mike
Post a Comment