2017-08-18 18 views
0

我在運行來自我的Bamboo服務器的EC2實例上的命令時遇到問題。 我有一個從AWS控制檯中的運行命令生成的命令。我將該命令放在我的竹服務器上的腳本中,並運行它: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中運行相同的命令:(*注意,這是我粘貼到Run Command控制檯中以生成代碼如上所述。)

$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命令有什麼區別?它不應該做同樣的事情嗎?

+0

凹凸...請幫忙!我很難過! –

+0

仍然掛在這...沒有?沒人能幫忙? –

回答

0

我覺得有一個引號和他們如何逃脫的方式搞砸了。

參見: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中運行它。

相關問題