Skip to content
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

WSL bash always returns host down #111

Closed
roughnecks opened this issue Feb 26, 2020 · 7 comments
Closed

WSL bash always returns host down #111

roughnecks opened this issue Feb 26, 2020 · 7 comments

Comments

@roughnecks
Copy link

roughnecks commented Feb 26, 2020

Hello, here's my script:

var ping = require('ping');
const fs = require('fs');

var hosts = ['192.168.1.253'];
hosts.forEach(function(host){
    ping.sys.probe(host, function(isAlive){
        if (isAlive) {
            return;
        } else {
            d = new Date().toLocaleString();
            fs.appendFile("/mnt/c/Users/roughnecks/Desktop/ping.txt", "Access Point is Down! - " + d + "\n" , function(err) {
                if(err) {
                    return;
                }
                //console.log("The file was saved!");
            });
        }
    });
});

This used to work but for some reason on my new WSL Debian install it always reports "host down",
Can you help?

roughnecks@CUSPIDE:~$ node --version
v12.16.1

roughnecks@CUSPIDE:~$ cat /etc/debian_version
10.3

Thanks

@mondwan
Copy link
Collaborator

mondwan commented Feb 26, 2020 via email

@roughnecks
Copy link
Author

roughnecks commented Feb 26, 2020

New script, just copy-pasted from README:

var ping = require('ping');

var hosts = ['192.168.1.253'];

hosts.forEach(function (host) {
    ping.promise.probe(host)
        .then(function (res) {
            console.log(res);
        });
});

roughnecks@CUSPIDE:~/scripts$ node pingpromise.js
{
host: 'unknown',
alive: false,
output: '',
time: 'unknown',
min: 'unknown',
max: 'unknown',
avg: 'unknown',
stddev: 'unknown'
}

@mondwan
Copy link
Collaborator

mondwan commented Feb 26, 2020 via email

@roughnecks
Copy link
Author

I have installed with:

npm install ping

Now I also tried with:

npm install node-ping

But it's still not working

@mondwan
Copy link
Collaborator

mondwan commented Feb 26, 2020 via email

@roughnecks
Copy link
Author

Yes, it's installed but it doesn't actually work.

"ping: socket: Operation not permitted"

I wonder how did I manage to have it working in my old setup, which was pretty much the same.

@roughnecks
Copy link
Author

roughnecks commented Feb 26, 2020

Hey, I fixed it by running this:

sudo chmod u+s which ping

Which was referenced here: microsoft/WSL#18 (comment)

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

No branches or pull requests

2 participants