Skarafaz / mercury

Simple Android app that sends pre-configured commands to remote servers via SSH.
GNU General Public License v2.0
115 stars 20 forks source link

Add option to use certain environmental variables when running a command #17

Closed doronbehar closed 5 years ago

doronbehar commented 7 years ago

I would like to run a command with mercury (fantastic app BTW) to launch an x application in an existing X session. But I guess mercury doesn't support it yet. Here is what I've done so far: I have succeeded to launch Firefox in an existing X session with connect bot. I ran inside the ssh session the following commands:

$ export DISPLAY=:0
$ firefox

And I saw Firefox being launched. Then I added the following to my JSON file:

{
    "name" : "testing DISPLAY",
    "cmd" : "export DISPLAY=:0 && firefox",
    "confirm" : false
},

It didn't work.. I guess there is a problem with the && expression.

What do you think?

Skarafaz commented 7 years ago

Yes, chaining commands with "&&" or ";" does not work at the moment!

As workaround, I suggest you to call a script:

{
    "name" : "firefox",
    "cmd" : "/path/to/script.sh",
    "confirm" : false
},
#!/bin/sh

export DISPLAY=:0
firefox

An option to run a command exporting some environment variables may be implemented soon.

ghost commented 5 years ago

Calling a script does not work for me, it just does nothing. I tried multiple scripts, which all work locally. Simple commands work very well, this app would be perfect for remotely controlling my raspberry pi

doronbehar commented 5 years ago

Perhaps you have forgotten to make your script executable with chmod?