Thursday, May 16, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2327  / 3 Years ago, tue, october 26, 2021, 12:20:04

I automate many processes on windows using batch files and putty.


E.g ( login_server7.bat ):


start C:UsersJackDocumentsputty.exe -ssh 1.1.1.1 -l user123 -pw "bleh"


How am I able to start an Ubuntu terminal and run a command automatically after opening a file?


Rather than manually opening the ubuntu terminal and typing my commands in?


Cannot see anything elsewhere on this topic. Regards


More From » command-line

 Answers
7

The executable of WSL is C:WindowsSystem32wsl.exe. You can just type wsl in Windows Command prompt and you will be logged-in to the default WSL instance. Or type wsl -h in order to get the list of all available options. In batch files you can use:


C:WindowsSystem32wsl.exe <your script or command>

Or if you need to run the command as root:


C:WindowsSystem32wsl.exe sudo <your script or command>

Probably more correct way is to use wsl -e -- <command>, but the above works nice for me. Here is more detailed example: Ubuntu 18.04 on WSL cron daemon not running after reboot.


[#927] Tuesday, October 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
vigorousom

Total Points: 394
Total Questions: 96
Total Answers: 110

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
vigorousom questions
Thu, Oct 6, 22, 16:53, 2 Years ago
Sun, May 15, 22, 08:14, 2 Years ago
Thu, Apr 6, 23, 22:39, 1 Year ago
Thu, Aug 25, 22, 07:55, 2 Years ago
;