[How-To] Use (some) external binaries in Tasker

801 views
Skip to first unread message

Wietse van Buitenen

unread,
Apr 6, 2014, 2:23:30 PM4/6/14
to tas...@googlegroups.com

When I switched from a rooted device to a new (non-rooted) one, I wanted to keep on using ssh and rsync from the “Run Shell” in Tasker as I did before.

With my rooted device I just pointed to the binary with needed options and added the command in the end:

/data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /data/data/com.magicandroidapps.bettertermpro/home/.ssh/identityfile -p 22 -l myuser 192.168.1.217 “zpool import -R /mnt backup;wait”


Without root I clearly couldn’t access /data/data/com.magicandroidapps.bettertermpro/.


Luckily I bumped into this link:

http://wiki.yobi.be/wiki/Android#Non-rooted_device

which showed how to copy rsync to the SSHDroid folder.


I figured the same could be done with Tasker so here we go..


For Tasker to call binaries directly, they need to be accessible by Tasker.

/sdcard is no good as we can’t set the execute bit on the filesystem.

We need to copy it to Tasker’s own folder /data/data/net.dinglisch.android.tasker/.


To keep everything clean I would advise to create a seperate folder where you will copy the binaries to ie. /data/data/net.dinglisch.android.tasker/custom/


Create the custom directory:

Tasker - File - Create Directory - Create All - /data/data/net.dinglisch.android.tasker/custom/bin


Copy the binary:

Tasker - File - Copy File - From /sdcard/mybinary to /data/data/net.dinglisch.android.tasker/custom/bin/


Set the correct permissions (you can probably tighten these permissions):

Tasker - Script - Run Shell - Command - chmod 755 /data/data/net.dinglisch.android.tasker/custom/bin/mybinary


Tasker - Script - Run Shell - Command - /data/data/net.dinglisch.android.tasker/custom/bin/mybinary


That’s it..

I have successfully used this for the ssh binary from BTEP (dropbear based) and the rsync binary (I also use rsync as a replacement for scp).

BusyBox binary also seems to work.

I couldn’t get the OpenSSH one from CyanogenMod running as it needed libssh.so which I can’t copy without root.


I can now do some cool stuff for which I previously needed root.


If you plan on using sqlite3 to access contacts or sms database, you will need root.

Databases on /sdcard or Tasker’s directory will pose no problem.


Have fun with it :)


grtz,
W.

Pent

unread,
Apr 7, 2014, 12:20:44 AM4/7/14
to tas...@googlegroups.com
Thanks for the clear explanation Wietse.

Pent

Antarion

unread,
Apr 7, 2014, 5:54:22 AM4/7/14
to tas...@googlegroups.com
Could this enable me to perform root-demanding Actions like pressing the music button?

Wietse van Buitenen

unread,
Apr 7, 2014, 11:41:08 AM4/7/14
to tas...@googlegroups.com
I don't think this method will be of much help for your needs..

Wouter Duverger

unread,
Apr 7, 2014, 11:42:57 AM4/7/14
to tas...@googlegroups.com
OK, thank you though :-)



--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/fQPgeGWLH2Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Wietse van Buitenen

unread,
Apr 11, 2014, 7:06:12 AM4/11/14
to tas...@googlegroups.com
huh, can't seem to edit my first post.. so I'll put it in a reply :)

I just tested with busybox-android which I downloaded from here:

because I needed "cat" and it works fine..

Paul V

unread,
Nov 29, 2014, 8:18:17 AM11/29/14
to tas...@googlegroups.com
Wietse, I cannot for the life of me get this to work. A small test program I wrote (to copy sqlite3 to a custom tasker dir) works perfectly on a rooted device - but the whole trick is of course superfluous on a rooted device.
Whereas the same program fails miserably on my as yet unrooted Nexus 10, with a bunch of Java errors and even sometimes taking Tasker down with it. So, I do not understand how you managed to do it. Or maybe Lollipop is to blame ?

Wietse van Buitenen

unread,
Nov 29, 2014, 9:11:45 AM11/29/14
to tas...@googlegroups.com
Hi Paul,
I am using several binaries this way on several devices, all unrooted (Sony Xperia Z1, Nexus 7 & HTC One).
At the time they all had KitKat (I think).
My Nexus 7 now has Lollipop so I'll test it out..

Is it copying of the binaries that actually fails or executing them?
If it's executing that fails, it's possible that your are trying to access a sqlite3 database from another app (like Contacts) where the Tasker user doesn't have the required rights.?

Paul V

unread,
Nov 29, 2014, 9:55:19 AM11/29/14
to tas...@googlegroups.com
Hi Wietse,
Just about everything ends in error: creating the custom dir, copying the file, chmodding it, and calling it. Of course, the first action ending in error causes all the rest to fail. And the final test statement simply tries to create a table in a test DB I created somewhere on the sdcard ...
Thx for your time - groetjes 😉

Paul V

unread,
Nov 29, 2014, 11:07:25 AM11/29/14
to tas...@googlegroups.com
Sorry for troubling you Wietse. After some more headscratching and testing, I found out that early in the process I must have created a FILE iso a directory, the presence of which subsequently caused all my next attempts to fail. Once I deleted this file, things went just as you outlined.
Big thx for your tip, and sorry to have bothered you ...

Wietse van Buitenen

unread,
Nov 29, 2014, 11:15:47 AM11/29/14
to tas...@googlegroups.com
Hi Paul,
glad you got it working, thanks for your feedback.
I was just testing on my Nexus 7 and while everything worked fine, it does seem that some binaries don't work anymore as Lollipop seems to need the binaries compiled in some other way.

I do plan on adding a Task here that will do all the needed stuff but I need to get around cleaning it up first :)

Anyway, eind goed al goed :)

Paul V

unread,
Nov 29, 2014, 11:28:43 AM11/29/14
to tas...@googlegroups.com
Yeah, I have the distinct impression Lollipop is going to cause more grief than fun :-(
Allow me to pick your brain one more time: do you think your trick can work for a kid app as well ? Suppose an unrooted device, without tasker ... So no tasker dir, no tasker executable with rights to its own dir, ... Where would one then copy the sqlite3 to, and execute it from ?
Examenvraag, vrees ik 😇

nanobrain

unread,
Nov 29, 2014, 12:37:00 PM11/29/14
to tas...@googlegroups.com
Look at this thread: https://groups.google.com/d/topic/tasker/raFenn0NJTM/discussion

tl;dr: Titanium Backup uses an sqlite3 binary that works on Lollipop 

Paul V

unread,
Nov 29, 2014, 12:57:59 PM11/29/14
to tas...@googlegroups.com
Thx for chiming in. That's the version I'm using, and got working. But I guess Wietse needs some more Lollipop-friendly modules ...

Wietse van Buitenen

unread,
Nov 29, 2014, 2:25:50 PM11/29/14
to tas...@googlegroups.com
I didn't test this but I would assume that the kid app will have its own directory where you should be able to move the binaries to.
An app has write and execute permissions in its own dir so I think this should work.

Paul V

unread,
Nov 29, 2014, 4:02:07 PM11/29/14
to tas...@googlegroups.com
I was hoping you'd say that. And fyi: I changed my little test program a bit, made it into a kid app ... and it seems to work.
Still, a lot of mumbo-jumbo for things that should be plain and straightforward ... :-(
Would you know of a way to find out the package name (and thus the name of its own data dir) of the kid app from within the app itself ?
At least I could then make this into a fairly universal subroutine in my apps ...

Jeremy Harris

unread,
Nov 29, 2014, 5:31:07 PM11/29/14
to tas...@googlegroups.com
Would you know of a way to find out the package name (and thus the name of its own data dir) of the kid app from within the app itself ?

Wouldn't that be the package name you assigned it when exporting the project?

Interesting thread. Glad it got bumped! :)

Wietse van Buitenen

unread,
Nov 29, 2014, 6:23:06 PM11/29/14
to tas...@googlegroups.com
I would also expect it to be the package name you can set when exporting.

Glad you find it interesting :)

Paul V

unread,
Nov 30, 2014, 7:55:45 AM11/30/14
to tas...@googlegroups.com
Of course me, myself & I know the package name. But what I'm after is the kid app finding out its own package name, so it knows where to copy its custom binary to ...

Jeremy Harris

unread,
Nov 30, 2014, 6:44:34 PM11/30/14
to tas...@googlegroups.com

The kid app will always have the package name that you defined.  So you would copy its custom binary to /data/data/thepackagenameyouassigned.  The kid app doesn't need to find it's own package name because it doesn't ever change. The programmer would just write the correct package name into the Copy action when developing the project. Make sure the package name you assign when exporting the project matches the name you used in that action, and you should be good to go.

:)

On 30 Nov 2014 07:55, "Paul V" <paul.van...@gmail.com> wrote:
Of course me, myself & I know the package name. But what I'm after is the kid app finding out its own package name, so it knows where to copy its custom binary to ...

Jeremy Harris

unread,
Dec 1, 2014, 9:20:38 PM12/1/14
to tas...@googlegroups.com
Here's a task I have in a kid app that refers to the apk in its own data directory. It extracts some files that are bundled into the apk and install them on the sd card on the initial run after install.

AB_Install Bible (306)
A1: Flash [ Text:Installing files! Please wait... Long:On ]
A2: Create Directory [ Dir:AutoBibleData/abtemp Create All:On Use Root:Off ]
A3: Copy File [ From:/data/app/com.jeremy.speakingbible-1.apk To:AutoBibleData/abtemp/com.jeremy.speakingbible.zip Use Root:Off ]
A4: UnZip [ File:AutobibleData/abtemp/com.jeremy.speakingbible.zip Delete Zip:Off ]
A5: Copy File [ From:AutoBibleData/abtemp/res/drawable/cust_ambilwarna_hue.png To:AutoBibleData/Bible.zip Use Root:Off ]
A6: Delete Directory [ Dir:AutoBibleData/abtemp Recurse:On Use Root:Off ]
A7: UnZip [ File:AutoBibleData/Bible.zip Delete Zip:On ]

Paul Vanderperren

unread,
Dec 3, 2014, 12:00:48 PM12/3/14
to tas...@googlegroups.com


Jeremy Harris wrote:

The kid app will always have the package name that you defined.  So you would copy its custom binary to /data/data/thepackagenameyouassigned.  The kid app doesn't need to find it's own package name because it doesn't ever change. The programmer would just write the correct package name into the Copy action when developing the project.

Hi Jeremy. This was already clear to me, but the reason I would like the app to be able to find out its own package's name is that I hate introducing literals in my programming. It is plain bad practice, to be avoided at (virtually) all cost - at least by me.
And if there is a way to do this, then the copy function (such as you described in your next post - thanks for that) could be written in a more 'universal' way, and dropped as-is in any project.
So, my question still awaits a genius's reply ;-)

Jeremy Harris

unread,
Dec 3, 2014, 12:58:05 PM12/3/14
to tas...@googlegroups.com

I would like the app to be able to find out its own package's name is that I hate introducing literals in my programming. It is plain bad practice, to be avoided at (virtually) all cost - at least by me.

Not to hijack the thread, but why is it bad practice? Sincere question... I'm a Tasker rookie with no programming experience... learning quickly, but thirsty for the how's and why's. (Maybe email me if you find the time?)

And if there is a way to do this, then the copy function (such as you described in your next post - thanks for that) could be written in a more 'universal' way, and dropped as-is in any project.

It's probably possible, but I'll have to defer to someone else.

You can use the Run Shell action for the "ps" command for a list of all packages on your device, then probably parse out the correct package name using variables...if you get it working, it could be a separate task that you always use in individual apk tasks using the Perform Task action.

Also, I could be wrong, but I vaguely remember Pent mentioning that he's considered adding an action to list package names...Not sure if/when that might come.

So, my question still awaits a genius's reply ;-)

Then I am DEFINITELY not your man, lol! But there are a few geniuses floating around here!

--

Wietse van Buitenen

unread,
Dec 3, 2014, 5:10:10 PM12/3/14
to tas...@googlegroups.com
So, my question still awaits a genius's reply ;-)

not that I feel addressed in any way but thought I'd post the limited info I have :)

I don't really see a way without any hardcoding at the moment..
the usual linux shell stuff (pwd, ~, $home, ..) doesn't return anything useful.
I know of no way to get the app name or apk name from the kid at runtime.
If we had that, we could use Run Shell with "pm list packages" to grab the package name and thus the dir..

so actually, I have nothing useful to offer :)

Matt R

unread,
Dec 3, 2014, 5:21:18 PM12/3/14
to tas...@googlegroups.com
With the next version of Tasker (or the current beta) you can use the java function getPackageName(). I tested it and got the Tasker package name. I assume it should work with kid apps.

Matt

Paul Vanderperren

unread,
Dec 3, 2014, 9:23:42 PM12/3/14
to tas...@googlegroups.com
Kudos to you, Matt. It works a treat, also from within a kid app. Thanks! Called for a genius, and got instant delivery :-)

Wietse van Buitenen

unread,
Dec 5, 2014, 2:34:05 AM12/5/14
to tas...@googlegroups.com
Nice one Matt, as usual ;-)
I can use this to make a distinction between the Direct Purchase Tasker and the Market one.
Thanks.

lakeside

unread,
Sep 20, 2016, 3:30:43 PM9/20/16
to Tasker
First off, this is an extremely valuable thread. Thanks.

Is there a way to package the sqlite3 binary with the kid app or does it need to be loaded onto the device separately (and then copied to /data/data/kid.app/custom/bin)?
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages