Page 1 of 1

Type commands in ubuntu app (WSL) from batch file in windows

Posted: 06 Jul 2021 14:25
by suman.iirs@gmail.com
I have a complex python based model that is executable only in linux environment. But it needs to be scheduled daily from windows operating system. So, I have installed ubuntu app in windows by activating the Windows subsystem for linux (WSL), and that is working fine when executed manually. But the real problem starts when I need to schedule the execution by using batch file. I am able to open the ubuntu app by using:

echo off
start ubuntu.exe

however, when entering any other command in the batch file (eg. changing the drive, start ubuntu.exe cd /mnt/d/), then the whole ubuntu terminal disappears. I guess the problem could be solved when it could be figured out that how to type commands into a ubuntu terminal by using cmd. Any help to give sort of lead is appreciated.

Thanks in advance

Re: Type commands in ubuntu app (WSL) from batch file in windows

Posted: 07 Jul 2021 10:27
by aGerman
You're heading in the wrong direction. Batch doesn't interact with any other window. And remote controlling of another application is the very last thing you should ever consider.

Directly use wsl.exe to execute your Linux command. E.g.

Code: Select all

wsl.exe "sleep 5s"
No cmd.exe or Batch script necessary, not even in a scheduled task.

Steffen