How do I timestamp every ping result?

I could not redirect the Perl based solution to a file for some reason so I kept searching and found a bash only way to do this: ping www.google.fr | while read pong; do echo “$(date): $pong”; done Wed Jun 26 13:09:23 CEST 2013: PING www.google.fr (173.194.40.56) 56(84) bytes of data. Wed Jun 26 13:09:23 … Read more

Using ping in c#

using System.Net.NetworkInformation; public static bool PingHost(string nameOrAddress) { bool pingable = false; Ping pinger = null; try { pinger = new Ping(); PingReply reply = pinger.Send(nameOrAddress); pingable = reply.Status == IPStatus.Success; } catch (PingException) { // Discard PingExceptions and return false; } finally { if (pinger != null) { pinger.Dispose(); } } return pingable; }

How to test an Internet connection with bash?

Without ping #!/bin/bash wget -q –spider http://google.com if [ $? -eq 0 ]; then echo “Online” else echo “Offline” fi -q : Silence mode –spider : don’t get, just check page availability $? : shell return code 0 : shell “All OK” code Without wget #!/bin/bash echo -e “GET http://google.com HTTP/1.0\n\n” | nc google.com 80 … Read more

Preferred Java way to ping an HTTP URL for availability

Is this any good at all (will it do what I want?) You can do so. Another feasible way is using java.net.Socket. public static boolean pingHost(String host, int port, int timeout) { try (Socket socket = new Socket()) { socket.connect(new InetSocketAddress(host, port), timeout); return true; } catch (IOException e) { return false; // Either timeout … Read more

ping response “Request timed out.” vs “Destination Host unreachable”

Destination Host Unreachable This message indicates one of two problems: either the local system has no route to the desired destination, or a remote router reports that it has no route to the destination. If the message is simply “Destination Host Unreachable,” then there is no route from the local system, and the packets to … Read more

Pinging servers in Python

If you don’t need to support Windows, here’s a really concise way to do it: import os hostname = “google.com” #example response = os.system(“ping -c 1 ” + hostname) #and then check the response… if response == 0: print hostname, ‘is up!’ else: print hostname, ‘is down!’ This works because ping returns a non-zero value … Read more

How do I determine if a port is open on a Windows server? [closed]

Assuming that it’s a TCP (rather than UDP) port that you’re trying to use: On the server itself, use netstat -an to check to see which ports are listening. From outside, just use telnet host port (or telnet host:port on Unix systems) to see if the connection is refused, accepted, or timeouts. On that latter … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)