简体   繁体   中英

Launch external program with multiple commands via Powershell

I am currently attempting to launch a different console (.exe) and pass multiple commands; while starting and entering a command works just fine, I haven't been able to find out how multiple ones can be entered via powershell.

& "C:\Program Files\Docker Toolbox\start.sh" docker-compose up -d --build

The given command works fine, but as mentioned I need to pass more than one command - I tried using arrays, ScriptBlocks and different sequences, though to no avail.

Edit :

Noticed that the docker build has a -f tag which allows me to specify a file; however, the issue now seems to be that the executed cmd removes all backslashes & special characters, rendering the path given useless.

Example:

&"C:\Program Files\Docker Toolbox\start.sh" 'docker-compose build -f 
path\to\dockerfile'

will result in an error stating that "pathtodockerfile" is an invalid path.

Your start.sh needs to be able to handle multiple arguments. This doesn't look like a PowerShell question

Turns out that it was easier than expected; Solved it by executing a seperate file that contained the two commands needed and passing it to the start.sh file.

&"C:\Program Files\Docker Toolbox\start.sh" './xyz/fileContainingCommands.sh'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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