如何让我的 .bat 文件运行 linux 命令到远程 linux [英] How do i make my .bat file run linux command to remote linux

查看:73
本文介绍了如何让我的 .bat 文件运行 linux 命令到远程 linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我当前的 .bat 内容.我在窗口 cmd 上运行它.它将连接到远程 linux 服务器并提示我输入密码.但是在我输入密码并以远程主机身份登录后,Linux 服务器不会运行我的 ls 命令.请帮忙.

Below is my current .bat content. i run it on window cmd. it will connect to remote linux server and prompt me password. but after i put the password and login as remotehost, linux server wont run my ls command. please help.

@echo off
ssh remotehost@10.1.1.10
ls

推荐答案

你真的应该做 man ssh ,因为这在那里有解释(你也可以在互联网上搜索以获得答案).

You really should do man ssh as this is explained there (and you could also make an internet search to get an answer).

但是,无论如何要回答您的问题:您应该将要在远程计算机上运行的所有命令与实际的 ssh 命令放在同一行,例如运行目录列表和 grep 所有包含foo"的文件,请执行: ssh @'ls|grep foo'.

But, to answer your question anyway: you should put all commands you want to run on the remote machine on the same line with the actual ssh command, for example to run directory listing and grep all files containing "foo", do: ssh <user>@<host> 'ls|grep foo'.

这篇关于如何让我的 .bat 文件运行 linux 命令到远程 linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆