简体   繁体   中英

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

Change the directory eg 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. I have cygwin.exe so that ssh string does work.

I'm reasonably certain this is the answer.

You launch ssh from the cygwin prompt ($) rather than directly from the cmd prompt. 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=... ; but if you're then going to run these from shortcuts the cd command needs to resolve the path better.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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