3

I can open ubuntu.exe using a .bat file by:

start ubuntu.exe

But I want to pass the parameter "./mnt/c/xxx.sh" to ubuntu.exe.

I.E. I want ubuntu.exe to launch a specific shell by using a .bat file, to ensure I don't have to open that particular shell every single time I open ubuntu.exe.

Can anyone give me some suggestions?

NotTheDr01ds
  • 17,888
Jane
  • 71
  • I close-voted for "unclear what your asking" as I don't understand a word of what you're talking about? ubuntu.exe? But could have voted for "Off-topic" as well because you tagged the question 14.04, which is EOL and thus unsupported here. – pLumo Jul 26 '19 at 06:57
  • @pLumo, I think the OP is referring to the Ubuntu Shell on Windows 10. "/mnt/c/...." gives the game away. :-p https://www.microsoft.com/en-au/p/ubuntu/9nblggh4msv6?rtc=1&activetab=pivot:overviewtab – tudor -Reinstate Monica- Jul 26 '19 at 07:22
  • I see ... thanks ;; then it should be off-topic as it's not about Ubuntu but Windows. – pLumo Jul 26 '19 at 07:24
  • I think they may be trying to do the equivalent of /bin/bash -c ".....". I don't have a Windows machine handy to see if that's possible with WS4L. – tudor -Reinstate Monica- Jul 26 '19 at 07:26
  • Thanks both of you. I found the solution. – Jane Jul 26 '19 at 07:53
  • Yes, it's the Ubuntu Shell on Windows10. – Jane Jul 26 '19 at 07:54
  • 2
    @pLumo Windows Subsystem for Linux has been deemed on topic here via discussion on meta and community practice. Only version specific questions should be closed as EoL, though it's hard to tell what is a version-specific question and what is not. I'm with you on not understanding the question, but it looks like that's our fault (or more kindly, lack of experience with WSL). – Zanna Jul 26 '19 at 12:27
  • Okay, I think I misunderstood a question or I'm still not sure. How to call ubuntu.exe from batch/.bat might be off-topic, something inside WSL on-topic. I don't think that the meta discussion exactly covers it. Imo it's a corner case. – pLumo Jul 26 '19 at 12:33
  • 1
    Edited! Useful for anyone else wanting to do this! – Fabby Jul 27 '19 at 08:33

2 Answers2

4

In the Ubuntu.exe help manual I found:

run < command line>
Run the provided command line in the current working directory.
If no command line is provided, the default shell is launched.

So in the .bat, I used:

start ubuntu.exe run /mnt/c/xxx.sh

It works well.

Fabby
  • 34,259
Jane
  • 71
  • Thank you for sharing your solution! :-) Could you please review my edits and also review the editing help to improve the readability of your questions and answers in the future... ;-) – Fabby Jul 27 '19 at 08:34
  • 1
    Thanks Fabby! I reviewed your edits, it's exactly what I want to say. Next time I'll be more careful about the edits. – Jane Jul 29 '19 at 01:14
  • You're welcome! That's what reviewers are for... ;-) – Fabby Jul 29 '19 at 20:29
0

Beside the answer that @Fabby mentioned, you can also run a command each time a shell is opened by adding your command at the end of the ~/.bashrc file. That is assuming you are using bash.

H H
  • 101