【问题标题】:AWS Run Command act different than running on server locallyAWS Run Command 的行为不同于在本地服务器上运行
【发布时间】:2018-02-22 06:27:50
【问题描述】:

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

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,因为没有浏览器显示...

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

$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(浏览器)是一个正常运行的常规应用程序。

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

运行命令 (send-command) 与在本地运行 PowerShell 命令有什么区别?它不应该做同样的事情吗?

【问题讨论】:

  • 撞...请帮忙!我被难住了!
  • 仍然挂在这个...什么都没有?没人能帮忙吗?

标签: powershell amazon-web-services amazon-systems-manager


【解决方案1】:

我认为引号和它们的转义方式有些混乱。

见:How to escape a double quote inside double quotes?

这个版本应该看起来更简单:

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 中运行它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    • 2019-08-30
    • 2015-04-30
    • 2018-08-16
    • 1970-01-01
    相关资源
    最近更新 更多