3

I am trying to run a script which launches a WSL (ubuntu1804) terminal, and then run a bash script in that terminal

.\ubuntu1804.exe;
cd test_directory;
node server.js;

However after the first command the terminal open however, the two other commands aren't executed

1 Answer 1

3

.\ubuntu1804.exe by itself opens an interactive shell which PowerShell executes synchronously.

That is, until you submit exit in that interactive shell to terminate it, control won't be returned to PowerShell, so the subsequent commands - cd test_directory and note server.js - are not only not sent to .\ubuntu1804.exe, as you intended, but are then run by PowerShell.

Instead, you must pass the commands to run to .\ubuntu1804.exe via the run sub-command:

.\ubuntu1804.exe run 'cd test_directory; node server.js'

Note: Once node exits, control will be returned to PowerShell.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.