Run Shell - Store Result In is empty

565 views
Skip to first unread message

Wietse van Buitenen

unread,
Nov 18, 2012, 11:55:32 AM11/18/12
to tas...@googlegroups.com
Hi Pent,

you introduced some fixes for Run Shell in the last release, they solve the 2 issues I had.
It really works great!

However :) .. I have one thing that 99% of the time returns an empty variable..
I would like to check if one of my servers is accessible through SSH so I try any of these:
/data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /data/data/com.magicandroidapps.bettertermpro/home/.ssh/server1 -p 22 -l root 192.168.1.251 "echo bla"
this should return bla

/data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /data/data/com.magicandroidapps.bettertermpro/home/.ssh/server1 -p 22 -l root 192.168.1.251 "nohup zpool status 2>&1 /dev/null &"
this should return the PID
this command returned the PID only once, the rest was empty and I tried a few times :)

both work fine from Android Terminal but when run in Tasker the variable selected in Store Result In becomes empty.
Before running the command I do a Variable Set to "begin" of the variable selected in Store Result In.

any ideas?

thanks in advance,
W.

Pent

unread,
Nov 18, 2012, 2:12:36 PM11/18/12
to Tasker
I've just noticed that I can get the error output from the command as
well (the '2' in your 2>&1). Will add a parameter to store that
somewhere for next time (not 1.3.3u2 though), maybe it gives us more
information.

Pent

Wietse van Buitenen

unread,
Nov 18, 2012, 4:18:59 PM11/18/12
to tas...@googlegroups.com
thanks, much appreciated!

I just remembered that during some tests I had a few commands that ran fine in an Android terminal but to get past them in Tasker I had to check "Continue on error".
The error output could indeed be useful to debug :)

Wietse van Buitenen

unread,
Nov 25, 2012, 6:00:51 AM11/25/12
to tas...@googlegroups.com
Hi Pent,

did some tests with 1.3.4b1 regarding the stuff below:

I would like to check if one of my servers is accessible through SSH so I try any of these:
/data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /data/data/com.magicandroidapps.bettertermpro/home/.ssh/server1 -p 22 -l root 192.168.1.251 "echo bla"
this should return bla

when I run it from Tasker with or without Root checked I get empty results if I Flash
Output: %result
Error: %stderr
Result: 0

when I copy/paste the whole command in the Android Terminal Emulator I get: bla

is it possible that Tasker shows the result of Run Shell and doesn't get the output of the ssh binary where Terminal does?

I added a log..
I hope there is an easy fix :)

have a nice sunny Sunday :)

grtz,
W.
shell_ssh
Message has been deleted

Wietse van Buitenen

unread,
Nov 25, 2012, 6:11:34 AM11/25/12
to tas...@googlegroups.com
huh... I replied to a mail and suddenly the whole thing turns up here.. weird..


On Sunday, November 25, 2012 12:01:24 PM UTC+1, Wietse van Buitenen wrote:
Hi Pent,

did some tests with 1.3.4b1 regarding the stuff below:

I would like to check if one of my servers is accessible through SSH so I try any of these:
/data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /data/data/com.magicandroidapps.bettertermpro/home/.ssh/server1 -p 22 -l root 192.168.1.251 "echo bla"
this should return bla

when I run it from Tasker with or without Root checked I get empty results if I Flash
Output: %result
Error: %stderr
Result: 0

when I copy/paste the whole command in the Android Terminal Emulator I get: bla

is it possible that Tasker shows the result of Run Shell and doesn't get the output of the ssh binary where Terminal does?

I added a log..
I hope there is an easy fix :)

have a nice sunny Sunday :)

grtz,
W.

Pent

unread,
Nov 25, 2012, 7:40:28 AM11/25/12
to Tasker
Sorry, I can't explain it.

Does it happen with anything else ?

Pent

Wietse van Buitenen

unread,
Nov 25, 2012, 7:54:41 AM11/25/12
to tas...@googlegroups.com
every Run Shell that I tested that uses the ssh binary seems to cause this issue..
haven't experienced it with anything else atm..

will do some more tests and also test with Secure Settings Run Command to compare

Wietse van Buitenen

unread,
Nov 25, 2012, 3:54:07 PM11/25/12
to tas...@googlegroups.com
Hi Pent,

I tested with 1.3.4b2 and created a loop for the:
/data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /data/data/com.magicandroidapps.bettertermpro/home/.ssh/server1 -p 22 -l root 192.168.1.251 "echo bla"
command, it retries as long as stdout doesn't match *bla*
in this case it's 16 times empty and then stdout is bla

I attached a log in case this might help.

I did test some other stuff but also with the ssh binary like above, once the server is of stderr becomes *No route to host* and when it's booting but ssh server isn't up *something like *connection denied*
shel_ssh_loop

ChrisD

unread,
Jan 11, 2013, 11:27:46 AM1/11/13
to tas...@googlegroups.com
Hi,

i have exactly the same issue with btep's ssh (v4.0.4) on a GT-i9300.

I call ssh from w/i a bash script with public keys on a server along the
lines of sth like

#!/bin/sh

RES=`ssh -i /path/to/key user@host "/path/to/script"`
echo $RES
exit


and expect a string back that i need to regex for further tasker action.

Stream redirection works as expected on the shell but as soon as i use
tasker to call "Run Shell" (non-root, continue on error, doesn't matter)
redirection fails (either to a file for output or to the variable using
"Store result in"). Other shell redirections work as expected and variables
get set w/"Store Result In".

So it must be an issue specific to ssh stderr/stdout redirection.

Btw: Calling ssh w/o the system call (backticks) has the same result.

I haven't tried the loop to see if the variable gets set at all, so far
i haven't had luck once with a lot of tests... any ideas?

If i can help w/ debugging, let me know how, thanks!

Chris

Wietse van Buitenen

unread,
Jan 12, 2013, 4:27:01 AM1/12/13
to tas...@googlegroups.com, andro...@christophe.danker.name
no idea sorry, for me this issue is also still open..

I shifted my focus to other Tasker Projects atm.
I do hope this will see a fix somewhere as Run Shell is soo powerful :)

If any more testing from me is needed just give a shout.

TomL

unread,
Jan 12, 2013, 5:27:19 AM1/12/13
to tas...@googlegroups.com
ChrisD, what about if you try this:

#!/bin/sh

RES=`/path/to/ssh -i /path/to/key user@host "/path/to/script"` ;
echo $RES ;
exit

Note the semicolons, and the path to ssh.

Tom

ChrisD

unread,
Jan 13, 2013, 3:04:27 PM1/13/13
to tas...@googlegroups.com
Hi Tom, hi Wietse,

should've been more specific. The path to ssh is included in my original
script to make sure the right one (btep's) gets called. Also: The remote
script does get executed, i just don't get any output back with "Store
Result In" vs when I call it from the shell diretly.

A simple test:

...

RES=`/data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /mnt/sdcard/sshkey user@host 'echo test'`;
echo $RES;
exit

...

with a Tasker task of

<TaskerData sr="" dvi="1" tv="1.3.3u2m">
<Task sr="task13">
<cdate>1357812962689</cdate>
<edate>1358106444953</edate>
<id>13</id>
<nme>storeResultInSshTest</nme>
<pri>10</pri>
<Action sr="act0" ve="3">
<code>123</code>
<se>false</se>
<Str sr="arg0" ve="3">sh /mnt/sdcard/sshTest.sh</Str>
<Int sr="arg1" val="50" />
<Int sr="arg2" val="0" />
<Str sr="arg3" ve="3">%SshResult</Str>
</Action>
</Task>
</TaskerData>


doesn't populate %SshResult with "test" while calling it directly from
btep does give "test" on stdout.



The semicolons didn't change anything unfortunately.


Thanks for your input!

Chris

TomL

unread,
Jan 14, 2013, 9:07:34 AM1/14/13
to tas...@googlegroups.com, andro...@christophe.danker.name
Have you tried changing in the RunShell action, the receiving variable from "%SshResult" (a global var) to "%sshresult" (a local var)?  Try an Alert > Notify %sshresult action immediately afterwards in the same task to see if anything came back.  If that works, then maybe the value of gobal var %SshResult is being trashed in another action.

This may make no difference, but I usually write my shell scripts like this:

#!/system/bin/sh
echo "Hello world";
exit;

, then I save them to /data/local/scripts and change them to world-executable and -readable.  I don't save them in /mnt/sdcard because Android forces /mnt/sdcard to not allow -executable permissions.  Then I call RunShell with simply "/data/local/scripts/HelloWorld.sh".  Again, this may make no difference in your case.

Have you tried using the Run Shell action in the plugin Secure Settings?  Maybe better redirection handling there?



Tom

schnee...@gmail.com

unread,
Jan 30, 2014, 6:45:01 AM1/30/14
to tas...@googlegroups.com
Hi all,

maybe no longer interesting, but having the same issue with Dropbears ssh client, i found the following.

According to this blog, Dropbears ssh in having problems with it's stdout and result codes if no stdin is present.

Using the following Run Shell action:

PATH_TO_BTEP/bin/ssh -i PATH_TO_BTEP/home/.ssh/somekey -l root targetmachine "ls; exit 13"

produces non deterministic results. Sometimes the resultcode is zero and stdout is not set, sometimes the resultcode is 13 and stdout has the correct output.

Changing the Run Shell action to this:

PATH_TO_BTEP/bin/ssh -i PATH_TO_BTEP/home/.ssh/somekey -l root targetmachine "ls; exit 13" </dev/zero

seems to always produce the correct output and resultcode. I tried 50 or so times, always the same (correct) result.


Perhaps helpful to someone

Frank
Reply all
Reply to author
Forward
0 new messages