How can I use Macrodroid to connect to remote SSH and execute commands?

aitn

Member
I want you to be specific about what you actually want to do, and that will change whether you really need SSH.
Right now it doesn't even tell me which is the server or the client.
I'm running out of time, so I'll reply when I have time, so please write in detail by then.
I have a bash script on my SSH server that I need to run
 

Dimlos

Well-known member
I've reread your question from the beginning, and I'm assuming you're saying it's okay if I can run Bash from PHP on Windows?
If so, that might be possible by installing WSL.

If you just want to run Bash, you don't have to do it on the server side, but you can use Termux to run Bash in a more unrestricted environment than MacroDoid's shell scripts.
 

Dimlos

Well-known member
As I have written many times, in order to get a clear answer, we need to be clear about what we want to do.
I understand that you want to run a script, but what does the script do?
I have no idea why it needs to be executed on the server side.
 

aitn

Member
As I have written many times, in order to get a clear answer, we need to be clear about what we want to do.
I understand that you want to run a script, but what does the script do?
I have no idea why it needs to be executed on the server side.
I figured it out, it's as simple as:

Scripting SSH commands​

Instead of opening an SSH terminal, sometimes it is desirable to simply execute a single command on a remote Linux computer from a Windows computer (EG from a script on the Window computer which performs other commands). This can be done using the plink command (which is also installed by default along with Putty):

plink -batch -pw password username@hostname bash_command

All I need now is to use the php to execute the command initiated by macrodroid.
 
Last edited:

Dimlos

Well-known member
I will report my verification results for the time being.
If you have WSL (Windows Subsystem for Linux) installed, you can run Bash from a batch.

Place the two files in the same directory as PHP(C:\PHP).

hello.sh
Code:
#!/bin/bash
echo "Hello world" > hello.txt

hello.bat
Code:
wsl bash /mnt/c/PHP/hello.sh
exit

When hello.bat is executed, hello.sh is executed by WSL and hello world is written to hello.txt.
 

aitn

Member
I will report my verification results for the time being.
If you have WSL (Windows Subsystem for Linux) installed, you can run Bash from a batch.

Place the two files in the same directory as PHP(C:\PHP).

hello.sh
Code:
#!/bin/bash
echo "Hello world" > hello.txt

hello.bat
Code:
wsl bash /mnt/c/PHP/hello.sh
exit

When hello.bat is executed, hello.sh is executed by WSL and hello world is written to hello.txt.
Thank you but the bash script has to run on the ssh server specifically on the machine it lives own. It’s not just running a bash script on Windows, plus turning on WSL feature slows down my Windows.
 
Top