Perhaps I am using the wrong keywords to find an answer to this requirement.
I have a GUI installed on a remote linux system that use remote connecting into it and initiating the application with X redirection, like this:
ssh -Y [email protected] cd /home/user.known/TheAppDir/ sh ./ApplicationCommand
with the above I have the GUI displayed on my local linux from the aServer
My question is – how can I write a bash on my local linux that would initiate the process above in one go? Ideally, I want to run a bash script like:
And I have the GUI running locally as a result?
If you create the file
aServer.ApplicationCommand (don’t forget the chmod +x to make it executable) and place in it:
#!/bin/bash ssh -Y [email protected] "cd /home/user.known/TheAppDir/ ; sh ./ApplicationCommand"
This should work. You will still be prompted for a password unless you have ssh keys configured.
SSH can be used strictly to run a command rather than return a session by placing the command after the SSH command. Essentially when doing this it opens a session, runs the provided command and then closes it.
Because you want multiple commands to be executed we simply place a semi-colon between to separate them and enclose in quotations so it remains an argument to the SSH command.
Rename the script to
aServer and change the script to:
#!/bin/bash ssh -Y [email protected] "cd /home/user.known/TheAppDir/ ; sh ./$1"
and call it using
aServer ApplicationCommand, the advantage to this is if you have multiple scripts in
TheAppDir that you want to call you just change the argument.
I think you can even still capture
$? to see if the script executed properly and create an error message if the file was not found, but you’d have to test that.