To run a shell script (with parameters) on Windows command line via putty.exe

17,759

Instead of using putty.exe, you can use pscp and plink (utilities that come with PuTTY) to do this. Use a command like this:

pscp.exe -pw "blabla" test-script.sh [email protected]:/some/path/

to copy the script to the remote server, and then use a command like this:

plink.exe -ssh -pw "blabla" [email protected] /some/path/test-script.sh ok-1

to execute it.

Share:
17,759
samantha
Author by

samantha

I am graduate software developer

Updated on September 15, 2022

Comments

  • samantha
    samantha over 1 year

    I need to execute a batch script which runs the shell script remotely inside the Linux box.

    Now, everything is working fine, but the script fails to execute if I try to give a command line parameter to the shell script.

    Working -> ex

    C:\temp\Testing>putty.exe -pw "blabla" -m "test-script.sh" [email protected]

    But if I try to give arguments it fails to execute. Example:

    Not Working

    C:\temp\Testing>putty.exe -pw "blabla" -m "test-script.sh ok-1" [email protected]

     where ok-1 = command line argument for local script test-script.sh
    

    How can I fix this problem?

  • samantha
    samantha almost 12 years
    Thanks for solution. Being late in Uk , I will try it tomorrow in office and let you guys know if it works. Thanks again
  • samantha
    samantha almost 12 years
    Hi @bta, I tried your command from cmd.exe on window but it fails . I got error like "bash: ok-1: command not found"
  • bta
    bta almost 12 years
    @samantha- Whoops, I made a typo on my plink command. There shouldn't be a colon between the server address and the command to run. See my edited answer for the correct syntax.