Search code examples
bashamazon-web-servicesamazon-ec2psexec

Running multiple commands on EC2 using psexec and AWS CLI


I'm trying to use CMD script to run two commands on Amazon EC2s using "psexec" command to run specific batch file to download specific file on these machines and the other command triggers .exe file to update SVN project, the problem is the current script runs the first action only and ignoring the other part of the "&&"

How can I make both actions run command, P.S I'm using FOR loop to run it on many EC2s?

Here is the script I'm using:

FOR /F "delims=" %%i in (D:\serverslist.txt) DO (psexec -u Administrator -p "password" \%%i -i "C:\project\script.bat" & "C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:update /path:"C:\project\" /closeonend:1) pause


Solution

  • I figured it out. I used ^&^& instead of && and it is working.

    The working script:

    FOR /F "delims=" %%i in (D:\serverslist.txt) DO (psexec -u Administrator -p "password" \%%i -i "C:\project\script.bat" ^&^& "C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:update /path:"C:\project\" /closeonend:1) pause pause