how to execute an local script in remote server with parameters

前端 未结 2 2087
遥遥无期
遥遥无期 2020-12-19 06:35

I have written an bash script foo.sh

#!/usr/bin/env bash
echo \"starting the script\";

I want to execute it in my remote server. I tried

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 06:57

    Use the -s option, which forces bash (or any POSIX-compatible shell) to read its command from standard input, rather than from a file named by the first positional argument. All arguments are treated as parameters to the script instead.

    ssh user@remote-addr 'bash -s arg' < test.sh
    

提交回复
热议问题