简体   繁体   English

如何从.bat文件在命令提示符下运行此命令?

[英]How can I run this command in command prompt from a .bat file?

Change the directory eg cd "Documents" 更改目录,例如cd "Documents"

then run the following: 然后运行以下命令:

ssh -i "miftah01.pem" ec2-user@ec2-52-91-88-181.compute-1.amazonaws.com

Whenever I try to do this, the .bat file only executes the directory change. 每当我尝试执行此操作时,.bat文件仅执行目录更改。 I have cygwin.exe so that ssh string does work. 我有cygwin.exe,以便ssh字符串起作用。

I'm reasonably certain this is the answer. 我可以肯定地说这就是答案。

You launch ssh from the cygwin prompt ($) rather than directly from the cmd prompt. 您从cygwin提示符($)启动ssh,而不是直接从cmd提示符启动。 I use batch files of the following form 我使用以下形式的批处理文件

PATH=C:\cygwin64\bin;%PATH%
cd %HOME%\"Documents"
ssh -i "miftah01.pem" ec2-user@ec2-52-91-88-181.compute-1.amazonaws.com

The command that makes it work is PATH=... ; 使它起作用的命令是PATH=... ; but if you're then going to run these from shortcuts the cd command needs to resolve the path better. 但是如果要通过快捷方式运行这些命令,则cd命令需要更好地解析路径。

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

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