0

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.

Cath
  • 460
  • 6
  • 21

2 Answers2

0

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

Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63
  • How'd I find out? start.sh is the file provided by Docker, and I have to run it as it configures all necessary proxy & VM settings. – Cath Jul 05 '17 at 14:06
  • @AscendedKitten Try quoting the arguments as a single string. `& 'C:\Program Files\Docker Toolbox\start.sh' 'docker-compose up -d --build'` – Maximilian Burszley Jul 05 '17 at 14:08
  • the arguments aren't the issue, as they are recognized - the issue lies in executing multiple commands, since I need to navigate to the right directory using cd before using docker-compose. – Cath Jul 05 '17 at 14:12
  • @AscendedKitten So you're trying to use PowerShell to send commands to a different program's console? – Maximilian Burszley Jul 05 '17 at 14:23
  • Exactly. Basically the rest of the script downloads some stuff, and in the end calls the program that actually processes that data. Though I do need more than one command to initialize that. – Cath Jul 05 '17 at 14:24
  • @AscendedKitten I'm not sure if that's possible. Here's a similar question I found: https://stackoverflow.com/questions/17205091/how-to-run-interactive-commands-in-another-application-window-from-powershell – Maximilian Burszley Jul 05 '17 at 14:28
  • Quite sure it is. Thanks for the link, but the answers all seem to be over-complicated for my case, considering that all I need is the ability to run two commands instead of 1. – Cath Jul 05 '17 at 14:33
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/148425/discussion-between-theincorrigible1-and-ascendedkitten). – Maximilian Burszley Jul 05 '17 at 14:52
0

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'
Cath
  • 460
  • 6
  • 21