bvv
bvv

Reputation: 3

PuTTY: pass parameter to .sh file

Is there a way to pass parameter to shell script which is run using PuTTY, i.e.:

putty -ssh myIp -l root -pw pwd -m myscript.sh param1

If I do so, PuTTY will not run myscript.sh. How do I pass param1 to it?

Upvotes: 0

Views: 2327

Answers (1)

MarcoS
MarcoS

Reputation: 17711

From Using PuTTY:

3.8.3.6

-m: read a remote command or script from a file

The -m option performs a similar function to the ‘Remote command’ box in the SSH panel of the PuTTY configuration box (see section 4.18.1). However, the -m option expects to be given a local file name, and it will read a command from that file.

With some servers (particularly Unix systems), you can even put multiple lines in this file and execute more than one command in sequence, or a whole shell script; but this is arguably an abuse, and cannot be expected to work on all servers. In particular, it is known not to work with certain ‘embedded’ servers, such as Cisco routers.

I.e., -m option expects to be given a file name, so you can put static parameters inside the file, but you can't pass them on the command line, sorry...

Upvotes: 2

Related Questions