简体   繁体   English

Linux:远程运行shell命令并打印结果

[英]Linux: Run a shell command remotely and print result

I want to create a script that runs shell commands on a remote Linux machine and print out the result. 我想创建一个脚本,在远程Linux机器上运行shell命令并打印出结果。 Some thing like a "run once" SSH. 有点像“运行一次”SSH。 Or for those familiar with Android development, something like "adb shell". 或者对于那些熟悉Android开发的人来说,就像“adb shell”。 For example, I want to run "ls" on my remote machine and display the results on the local host. 例如,我想在远程计算机上运行“ls”并在本地主机上显示结果。

This is supported directly by ssh: 这由ssh直接支持:

ssh [options] [user@]hostname [command]

eg 例如

ssh user@host ls

If not command is given an interactive shell is usually run by default. 如果没有给出命令,则通常默认运行交互式shell。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM