2

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

ebk
  • 305
  • 8
  • 20

1 Answers1

5

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

Carlos Rafael Ramirez
  • 5,984
  • 1
  • 29
  • 36
  • Thanks for your reply.i think its working upto sudo service supervisor start. is there any issues on these two commands? cd /home/frappe/frappe-bench sudo bench start – ebk Aug 10 '19 at 12:50
  • sudo bench start looks strange for me but I don't know this tool. If it runs right inside the WSL session I don't see reasons why they wouldn't outside. Maybe you can add login session to bash: `bash -l -c ./ErpStartupService.sh` – Carlos Rafael Ramirez Aug 11 '19 at 13:39