The second parameter is the script to execute. Scripts should be stored in /accounts/1000/shared/misc/bron/scripts/ on the flash of your device. A script is just that; a shell script written in ksh and designed to do something of value on your BlackBerry 10 device.
The best way to prepare scripts is to download the BlackBerry 10 NDK which includes the Momentics IDE. The IDE makes it easy to ssh to your device and get a shell. From there, you can create your scripts and when you’re satisfied, you can copy your scripts to the noted directory. Of course, you can copy scripts to your device over the file share (if file sharing is enabled) as well. Once the scripts are on your device, in the right directory, you can edit them within the app too. This makes it easy to tweak things, or adjust parameters or variables without leaving the app.
BlackBerry has some good documentation on the shell too!
Scripts should source the environment variable file at /accounts/1000/shared/misc/bron/conf/env-vars.txt to have access to environment variables that may be of use to your script. For the moment, the only one defined is $BRONDIR which resolves to /accounts/1000/shared/misc/bron. You can set this variable yourself if you’d rather not source the file for whatever reason. Here’s how to source the file:
#!/bin/sh # example script . /accounts/1000/shared/misc/bron/conf/env-vars.txt echo $BRONDIR
which would produce output like:
Scripts should log output to $BRONDIR/logs/`basename $0 .sh`.log in order to be viewable in the app. I recommend assigning this to a variable at the top of your script so you can use it consistently throughout your scripts. The same construct is also used for Notifications (see below). For example:
#!/bin/sh . /accounts/1000/shared/misc/bron/conf/env-vars.txt export myName=`basename $0 .sh` ... echo "something useful for the log.." >> $BRONDIR/logs/$myName.log
If your script produces something noteworthy that you’d like to be notified of, you can create an Notification by writing output to $BRONDIR/alerts/<$basename>.notification. BRON will look for this file when your script finishes executing, and if found, will put a notification in the Hub with the contents of this file. For example:
#!/bin/sh . /accounts/1000/shared/misc/bron/conf/env-vars.txt export myName=`basename $0 .sh` echo "`date` : something happened, but it's not that important..." >> $BRONDIR/logs/$myName.log echo "`date` : SOMETHING IMPORTANT HAPPENED!" >> $BRONDIR/alerts/$myName.notification
will produce a notification like this in the Hub:
There are lots of commands available in the BlackBerry 10 shell. I encourage you to experiment, poke around, see what you can find out.
For example, you can copy files to your Box account (assuming you are logged in using the Box app for BlackBerry 10) by doing something like this:
cp -Rn /accounts/1000/shared/documents /accounts/1000/shared/Box/documents-from-my-device # or from Box to your SD card cp -Rn /accounts/1000/shared/Box/MyMusic /accounts/1000/removable/sdcard/music
You can do similar to or from any computers you have linked up through Link as well… lots of possibilities…
The cp command is also worth looking at, notably the -n option. go explore!