Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to run a simple bat file from windows that will run a bash script on linux machine. The bash script is located on the linux machine.

For example: I'm trying to run this bat file from windows

plink.exe -pw <password> root@<ip> bash -c "/root/script.sh"

Result:

  • When running from windows the cmd is stuck forever
  • when running the specific script (/root/script.sh) from the linux machine it's working just fine.
  • The script contain ruby code and I'm using RVM
share|improve this question
    
Does the script require any interaction? What happens if you run bash -c "/root/script.sh &" instead? –  Daniel Andersson Apr 18 '12 at 11:02
add comment

1 Answer 1

what do you see if you run the following? this will step through the script.

plink.exe -pw <password> root@<ip> bash -x "/root/script.sh"

also, be aware that the environment set up is different when you run remotely. you must make sure that all that is set up properly, such as PATH. so your script must say either /usr/bin/ruby instead of ruby, or add /usr/bin in the PATH, etc.

Or source a file that will set them up.

share|improve this answer
    
I'm getting the following error: "/bin/sh: cannot execute binary file –  user128877 Apr 19 '12 at 6:36
    
ok, then change bash to /bin/bash, or /bin/sh and try again. –  johnshen64 Apr 19 '12 at 12:10
    
How should I write on windows? I'm running this from windows machine to linux machine –  user128877 Apr 19 '12 at 12:33
    
plink.exe -pw <password> root@<ip> /bin/bash -x "/root/script.sh" –  johnshen64 Apr 19 '12 at 12:43
    
plink.exe -pw <password> root@<ip> /bin/sh -x "/root/script.sh" –  johnshen64 Apr 19 '12 at 12:43
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.