简体   繁体   English

从cmd登录到Bash并在一行中运行命令

[英]From cmd, log into Bash and run command in one line

I am developing a TIBCO application and need to be able to run a scp command from an external command resource. 我正在开发TIBCO应用程序,并且需要能够从外部命令资源运行scp命令。

Anyway the issue boils down to being able to log in to bash.exe then run my scp command in the same line. 无论如何,问题归结为能够登录到bash.exe,然后在同一行中运行我的scp命令。

it works when I run (from cmd.exe) 它在我运行时有效(来自cmd.exe)

c:\cygwin\bin\bash.exe --login

(I enter bash) (我输入bash)

Then I can run my scp statement just fine 然后我可以运行我的scp语句

scp account@server:~mysourcedirectory/targetfilename* /cygdrive/c/targetfolder

I want to do these two things in the same line but it doesnt work, aka 我想在同一行中做这两件事,但又行不通

 c:\cygwin\bin\bash.exe --login -c scp account@server:~mysourcedirectory/targetfilename* /cygdrive/c/targetfolder

will fail. 将失败。 What am I doing wrong and how can i run this command in one go? 我在做什么错,如何一口气运行此命令?

Thanks 谢谢

You have to quote the command. 您必须引用命令。

c:\cygwin\bin\bash.exe --login -c "scp account@server:~mysourcedirectory/targetfilename* /cygdrive/c/targetfolder"

Tested using cmd in wine in gnu/linux. 在gnu / linux的wine中使用cmd进行了测试。 Single quotes did not work, I don't know all the quoting rules for cmd. 单引号无效,我不知道cmd的所有引号规则。 But the above did work. 但是以上确实有效。

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

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