否在线我可以找到从另一个脚本在远程服务器上运行shell脚本的方法。这是为了自动化,因此主机上的脚本将自动触发另一台服务器上的另一个脚本。我的脚本将ssh到的服务器将具有密码提示或设置RSA密钥对
谢谢!
答案 0 :(得分:3)
只需将命令作为参数传递给ssh。
ssh someserver /path/to/some/script.bsh
答案 1 :(得分:0)
假设您要在node2上执行脚本,但是在node1上拥有脚本,脚本的文件名为 sp ,位于位置/ home / user / sp。
Uri contentUri = Uri.fromFile(f);
String mString = "email@example.com";
try {
ExifInterface exif = new ExifInterface(contentUri.getPath());
exif.setAttribute("Email" , mString);
exif.saveAttributes();
} catch (IOException e) {
e.printStackTrace();
}
答案 2 :(得分:0)
另一种方式,使用expect package
。
免责声明:因为它具有一个 打开密码。但取决于您的用例
如果服务器没有expect
,则可以添加软件包。运行命令。您还可以将此命令放在.sh
脚本中。
expect -c 'spawn ssh user@10.11.12.13 "/path/to/my.sh"; expect "assword:"; send "Y0urp@ssw0rd\r"; interact'