1

I have Windows box and I wish to invoke a .sh script on a remote Unix server.

Can someone help me with the command if it is possible using WinSCP?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
shifahim
  • 127
  • 1
  • 7
  • 19

2 Answers2

1

Please refer to https://winscp.net/eng/docs/scripting#different_account

But I suggest to use a SSH client such as PuTTY or Bitvise Tunnelier to execute some command on remote server.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Frank He
  • 536
  • 3
  • 9
  • Can you give me an example for putty to be specific. – shifahim Jul 04 '12 at 14:40
  • Well. If you have the .sh file already, you can just upload the .sh file to server use WinSCP and login to server use Putty. – Frank He Jul 04 '12 at 14:45
  • And, in Putty, in the directory contains the .sh file, issue commands: chmod a+x xxx.sh; ./xxx.sh – Frank He Jul 04 '12 at 14:46
  • I am sorry but my question is not understood. The link shared as an answer http://winscp.net/eng/docs/scripting#running_a_script_under_a_different_account_e.g._using_a_scheduler talks about executing the script "example.txt" on my local windows machine. What I am looking for is executing the example.sh which is on a remote unix machine from my local windows machine using winscp or putty – shifahim Jul 04 '12 at 14:55
  • I have my putty.exe in "C:\test" folder. Can you give me the command to use putty to connect to the remote host then move to the directory which has my .sh file and the command to execute the .sh – shifahim Jul 04 '12 at 14:59
  • Run putty, fill in Hostname with same as you use in WinSCP. Press Open, and after connection successfully, you will be prompted to input username and password. – Frank He Jul 04 '12 at 15:03
  • So, is there no way of automating this ? My ultimate goal is to run some cmd script in windows and it should connect to a remote unix host and run a script x.sh located on the remote unix host. I was wanting to achieve this by using WinSCP and Putty only. If possible let me know how and if not then what is the minimum number of tools I can use to chieve this and how. – shifahim Jul 05 '12 at 07:47
  • Please check "Running a Command on a Remote Machine" part in http://www.cabrillo.edu/~jgriffin/files/putty.html or refer to http://stackoverflow.com/questions/6147203/automating-running-command-on-linux-from-windows-using-putty – Frank He Jul 06 '12 at 06:30
1

To invoke a remote command using WinSCP, use the call command.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992