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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
suman.iirs@gmail.com
Posts: 1
Joined: 06 Jul 2021 13:56

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

#1 Post by suman.iirs@gmail.com » 06 Jul 2021 14:25

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

aGerman
Expert
Posts: 4195
Joined: 22 Jan 2010 18:01
Location: Germany

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

#2 Post by aGerman » 07 Jul 2021 10:27

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

Post Reply