相关疑难解决方法(0)

Shell脚本:通过ssh从脚本运行函数

有什么聪明的方法可以通过ssh在远程主机上运行本地Bash功能吗?

例如:

#!/bin/bash
#Definition of the function
f () {  ls -l; }

#I want to use the function locally
f

#Execution of the function on the remote machine.
ssh user@host f

#Reuse of the same function on another machine.
ssh user@host2 f
Run Code Online (Sandbox Code Playgroud)

是的,我知道它不起作用,但有没有办法实现这一目标?

linux bash shell sh

39
推荐指数
3
解决办法
3万
查看次数

标签 统计

bash ×1

linux ×1

sh ×1

shell ×1