Skip to content

[WSL2] getWslSSHAddress would fail on busybox distros #3242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arixmkii opened this issue Feb 16, 2025 · 1 comment · Fixed by #3299
Closed

[WSL2] getWslSSHAddress would fail on busybox distros #3242

arixmkii opened this issue Feb 16, 2025 · 1 comment · Fixed by #3299

Comments

@arixmkii
Copy link
Contributor

arixmkii commented Feb 16, 2025

Description

The command line used is not universally supported:

cmd := exec.Command("wsl.exe", "-d", distroName, "bash", "-c", `hostname -I | cut -d ' ' -f1`)

Example output from Alpine:

~$ hostname -I
hostname: unrecognized option: I
BusyBox v1.37.0 (2024-12-13 21:18:49 UTC) multi-call binary.

Usage: hostname [-sidf] [HOSTNAME | -F FILE]

Show or set hostname or DNS domain name

        -s      Short
        -i      Addresses for the hostname
        -d      DNS domain name
        -f      Fully qualified domain name
        -F FILE Use FILE's content as hostname
~$ echo $?
1
@arixmkii arixmkii changed the title getWslSSHAddress would fail on busybox distros [WSL2] getWslSSHAddress would fail on busybox distros Feb 16, 2025
@arixmkii
Copy link
Contributor Author

If there is ip command then this command chain produced the needed result for me on Ubuntu and Alpine ip -4 -o addr show eth0 | awk '{print $4}' | cut -d/ -f1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants