ebk
ebk

Reputation: 335

How to execute a .sh file from windows batch file in wsl

I am trying to execute a .sh file inside ubuntu from .bat file inside windows.

I have tried following code

cd "C:\Program Files\Ubuntu\Ubuntu"
start ubuntu1804.exe run ErpStartupService.sh

and my ErpStartupService.sh is

#!/bin/bash
sudo service mysql start
sudo service nginx start
sudo service redis-server start
sudo service supervisor start
cd /home/frappe/frappe-bench
sudo bench start
read -p "$*"

if i am running ErpStartupService.sh as ./ErpStartupService.sh from ubuntu terminal everything is executing as expected.but if i run bat file terminal is disappearing and not able to understand what is happening.i am using ubuntu 18.0.4 as wsl

Upvotes: 4

Views: 5864

Answers (1)

Carlos Rafael Ramirez
Carlos Rafael Ramirez

Reputation: 6234

You are almost there. Don't use start.

bash.exe -c ./ErpStartupService.sh

or

ubuntu1804.exe run bash -c ./ErpStartupService.sh

Just play a bit

Regards

Upvotes: 5

Related Questions