AWS Run Command的行为不同于在本地服务器上运行的行为 [英] AWS Run Command act different than running on server locally

查看:154
本文介绍了AWS Run Command的行为不同于在本地服务器上运行的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Bamboo服务器上的EC2实例上运行命令时遇到问题. 我有一个从AWS控制台中的Run Command生成的命令.我将该命令放在竹服务器上的脚本中并运行它:

I am having problems running commands on an EC2 Instance from my Bamboo server. I have a command generated from the Run Command in the AWS Console. I place that command in a script on my bamboo server and run it:

aws ssm send-command --document-name "AWS-RunPowerShellScript" --targets '{\"Key\":\"tag:Name\",\"Values\":[\"Auto-Scaling-Group\"]}' --parameters '{\"commands\":[\"$fileEXE = \\\"C:\\\\Program Files (x86)\\\\NUnit\\\\NUnit.ConsoleRunner.3.7.0\\\\tools\\\\nunit3-console.exe\\\\\\\"\",\"$testDll = \\\"C:\\\\TestFramework\\\\TestFramework\\\\Tests\\\\bin\\\\Debug\\\\TESTS.dll\\\"\",\"[System.Diagnostics.Process]::Start($fileEXE,$testDll)\"]}' --comment "Run Test UI Testing" --timeout-seconds 600 --region us-east-1

它确实运行测试.但它会运行Chrome.exe浏览器和chromedriver.exe作为后台进程.这会引发NoSuchWindowException,因为没有浏览器出现...

It does run the tests. But it runs the Chrome.exe browser AND the chromedriver.exe as background processes. This throws a NoSuchWindowException because there is no browser showing up...

我可以在本地实例上在PowerShell中运行相同的命令:(*请注意,这是我粘贴到运行命令"控制台中以生成上述代码的同一命令.)

I can run the same command in PowerShell on the instance locally: (*Note that this is the same command I pasted into the Run Command console to generate the code mentioned above.)

$fileEXE = "C:\Program Files (x86)\NUnit\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe\"
$testDll = "C:\TestFramework\TestFramework\Tests\bin\Debug\TESTS.dll"
[System.Diagnostics.Process]::Start($fileEXE,$testDll)

效果很好. chromedriver.exe是一个后台进程,而chrome.exe(浏览器)是一个正常运行的常规应用程序.

It works just fine. chromedriver.exe is a background process and chrome.exe (the browser) is a regular app that works like normal.

我相信我的问题是Run Command如何运行我的测试程序.

I believe my problem is how Run Command is running my test program.

运行命令"(发送-command )并在本地运行PowerShell命令?它不应该做同样的事情吗?

What is the difference between Run Command (send-command) and running the PowerShell commands locally? Shouldn't it do the same thing?

推荐答案

我认为引号和引号的转义方式很混乱.

I think there is a mess up with quotes and the way how they're escaped.

请参阅:如何在双引号内转义双引号?

此版本应该看起来更简单:

This version should look much simpler:

CMD='$fileEXE = "C:\Program Files (x86)\NUnit\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe";'
CMD+='$testDll = "C:\TestFramework\TestFramework\Tests\bin\Debug\TESTS.dll";'
CMD+='[System.Diagnostics.Process]::Start($fileEXE,$testDll);'

aws ssm send-command --document-name "AWS-RunPowerShellScript" \
  --filters "Name=tag:Name,Values=Auto-Scaling-Group" \
  --comment "Run Test UI Testing" --timeout-seconds 600 --region us-east-1 \
  --parameters commands="'$CMD'"

注意:在Bash shell中运行它.

这篇关于AWS Run Command的行为不同于在本地服务器上运行的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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