Execute local script requiring arguments on Linux via plink
5,613
I had the same issue.
You can simply write this line
plink 1.2.3.4 -l root -pw pass " myscript.sh arg1 arg2"
For example, I had to run a script and give two files as parameters.
plink 1.2.3.4 -l root -pw pass " myscript.sh path/to/file1 path/to/file2"
Related videos on Youtube
![c_maker](https://i.stack.imgur.com/GQXfx.png?s=256&g=1)
Author by
c_maker
Updated on September 18, 2022Comments
-
c_maker almost 2 years
Is it possible to execute (from windows) a local script with arguments on a remote linux system?
Here's what I got:
plink 1.2.3.4 -l root -pw mypassword -m hello.sh
Is there a way to do this same thing, but able to give input parameters to hello.sh?
I've tried many things, including:
plink 1.2.3.4 -l root -pw mypassword -m hello.sh input1 input2
In this case it seems that plink thinks that input1 and input2 are its arguments.. which makes sense.
What are my options?
-
c_maker over 12 yearsDoes not work for me. Am I supposed to replace '$SHELL' with something? is arg1 supposed to be the name of the file? I've tried all kinds of combinations, nothing seems to work. My hello.sh looks like this: '#!/bin/bash echo "Your argument is "$1'.
-
user1686 over 12 years@c_maker: Try the updated version; and no, $SHELL will be automatically expanded on the server, and arg1 is the first argument you want to give.
-
martonbognar almost 6 yearsI don't think is is the same issue OP described, in this case the executed script resides on the remote machine, doesn't it?