Anybody familiar with WSL?


  1. Posts : 740
    Windows 10 x64 Pro
       #1

    Anybody familiar with WSL?


    Having a problem (i believe?) thats always been a thing. Would like to understand the cause and remedy it.

    I had a developer buddy throw together a few scripts for me in order to do something I needed that would have been impossible manually. For better or worse, he hasnt touched windows in a lot of years, therefore they came as .bash

    I sorted out how to run them and they did their job just fine. Somewhere along the way, i stumbled upon another developer who tossed together a registry package to allow execution of them via double clicking. Win for useability and parity in general, and ive been using that - again without fail.

    However the other day i noticed that relative to most scripts (all?) that ive ran .. ever. The bash scripts output nothing to the console window. execute the script and i get a cursor until its done. and some of them take a loooong while so you never know.

    Ive become accustomed to this being the case but id prefer to have them output to the window so i can see theyre running and potentially see if one got stuck or had an issue etc etc.

    I reached out to my associate, and he mentioned that in native linux they output, however he's unsure how it works with WSL so was unable to offer assistance.

    Anybody able to guide me on this one?
      My Computer


  2. Posts : 2,068
    Windows 10 Pro
       #2

    Well, a script in Linux is only going to output to the screen if it's been configured to output to the screen. The configuration however is built into the script itself, not the OS or the environment. So, unfortunately in this case there isn't a setting you can just enable to get more output from your scripts.
      My Computers


  3. Posts : 740
    Windows 10 x64 Pro
    Thread Starter
       #3

    pparks1 said:
    Well, a script in Linux is only going to output to the screen if it's been configured to output to the screen. The configuration however is built into the script itself, not the OS or the environment. So, unfortunately in this case there isn't a setting you can just enable to get more output from your scripts.
    ok, thats what i was sort of surmising. nothing simple like an $echo type thing I can add to the top of each script i imagine? Lol

    I got another one for ya (if your versed). Im trying to set this up on two pc's. The first pc, if i right click the script Open With.. and choose Microsoft Bash Launcher, it opens quickly and closes.

    on the second, if i do that - it runs the script and stays open. No idea whats going on w/ that ><

    - - - Updated - - -

    so i figured it out. scripts need ```set -x``` to enable output.
      My Computer


  4. Posts : 1,656
    Windows 10 Pro x64
       #4

    klepp0906 said:
    so i figured it out. scripts need ```set -x``` to enable output.
    Thats correct, set -x is a standard debug routine in BASH. Depending on the complexity of the script, it may add additional run time as all the output is echoed/parsed to stdout (the monitor). If you want to turn it off again, use set +x.

    An alternative is to use set -e to only echo output to the screen when an error is encountered in the script.
      My Computers


  5. Posts : 1,689
    X
       #5

    When I run shell scripts from a registry key, the "target" is:
    Code:
    C:\Windows\System32\bash.exe -i -c "/mnt/c/...<PATH TO SCRIPT FILE> '%1'"
    (assuming one command line argument as '%1').
    This creates a console window and all script output goes there.
      My Computer


  6. Posts : 740
    Windows 10 x64 Pro
    Thread Starter
       #6

    margrave55 said:
    When I run shell scripts from a registry key, the "target" is:
    Code:
    C:\Windows\System32\bash.exe -i -c "/mnt/c/...<PATH TO SCRIPT FILE> '%1'"
    (assuming one command line argument as '%1').
    This creates a console window and all script output goes there.
    yea im admittedly brand spanking new to linux. I've been launching them via this
    Need some solid linux/wsl &gt; windows registry help

    which results in no output whether i use an "open bash here" type context menu item, or via the double click method.

    unsure how the /mnt/etc ties in.

    working on fixing it as we speak. day 2 :P

    if theyre supposed to output natively and dont, perhaps im barking up the wrong tree w/ set -x

    - - - Updated - - -

    yea i dunno. i generically opened bash.exe
    did a cd /mnt/drive/scriptdir

    ran ./scriptname.bash

    got a cursor with no output. Script was running, but blank. My linux dev contact says set -x isnt required in native linux and is generally undesirable.

    this is well beyond me :P

    - - - Updated - - -

    a bit of digging, and a bit more digging on top of that. finally.. i think some vindication. Sounds like theres "technically" nothing wrong anyhow.

    from my primitive brains understanding, sounds like no output is expected from WSL.

    Anybody familiar with WSL?-image.png
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 09:33.
Find Us




Windows 10 Forums