• Ever wanted an RSS feed of all your favorite gaming news sites? Go check out our new Gaming Headlines feed! Read more about it here.
  • We have made minor adjustments to how the search bar works on ResetEra. You can read about the changes here.
Status
Not open for further replies.
Oct 27, 2017
12,294
Scenario:
I have a Linux computer that I have a program on that I want to remotely run from my Windows computer. This is all happening locally within my own network.

I have enabled SSH on the box and I can connect to it in putty and I can remotely initiate it using my command...

However I want to be able to create a batch file that will do it in one click.

Is there a way to do this? I essentially want to initiate the SSH, login, navigate to a directory and run a command in a single click of a batch file. Is this possible?
 

Trouble

Member
Oct 25, 2017
6,140
Seattle-ish
I don't fuck with .bat, but here's a basic shell script
Code:
#!/bin/sh
ssh <host> sh -c 'cd <dir>; <command>'

E: If you need to use putty, maybe this.
 
OP
OP
kyle mechlachlan
Oct 27, 2017
12,294
I don't fuck with .bat, but here's a basic shell script
Code:
#!/bin/sh
ssh <host> sh -c 'cd <dir>; <command>'

E: If you need to use putty, maybe this.
I don't necessarily need putty. I can also ssh from CMD as well. Either works.

I'm not sure how to run a shell script from Windows? I created the script and named it .sh?
 

Trouble

Member
Oct 25, 2017
6,140
Seattle-ish
I don't necessarily need putty. I can also ssh from CMD as well. Either works.

I'm not sure how to run a shell script from Windows? I created the script and named it .sh?
No idea if shell scripts work in the regular windows shell these days, but probably not. Should work using WSL.

You should be able to create a .bat using the same ssh command if you have an ssh binary that you can run from the cli.
 
Status
Not open for further replies.