Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP-Pinger

Empfohlene Antworten

Veröffentlicht

Hallo Leute!

Ich hab mir überlegt ein PHP-Pinger zu bauen ich hoffe das is überhaupt gescheit möglich... Könnt ihr mir dabei helfen?

Also der Zweck ist das bei dem Aufruf der PHP-Datei alle IP`s durchgepingt und im Fall das die IP nicht erreichbar ist etwas passiert... Nunja also liefert mir das auch en Errorlvl ins PHP zurück?

Ich hab da mal sowas kleines geproggt... Könnt ihr mir helfen? Geht das so?


<?php
$fp1 = echo exec("ping -w 4000 -c 1 192.168.0.2");
$ok1 = %ERRORLEVEL%==0;
if ($fp1 == $ok1)
{ print "Server A checked.<br>"; }
else
{
print "! - Server A DEAD - !<br>";
}
[/PHP]

Hm dürfte net gehn oder?

Hi,

auf was für nem BS proggst du denn ?

der Ping Befehl ist afaik in der falschen Reighenfolge:

ping 192.168.0.2 -w 4000

Dann läuft das. Habs als CLI getestet.

Oh vergessen: Das echo vor exec muss weg.

MfG

Das echo muss weg ja... klar hatte ich irgendwie ka :D nunja aber es geht auch so du kannst die parameter auch so mitgeben... nur meine frage ist geht das so ? bekomme ich da ein errorlvl zurück ins php? ;):P:rolleyes:

Also unter windoof (da hab ich das mal gemacht) bekommst du mit

$var = exec...

in $var die letzte Zeile der Programmausgabe zurück in dem Fall "gesendet x empfangen x ..."

Wenn du exec("Befehl", $ret) nimmst steht in $ret die komplette Ausgabe des Programms in Form eines Arrays.

so kann das z.B. aussehen

exec("ping 192.168.1.10 -w 4000",$ret);

if ($ret[3] == "Zielhost nicht erreichbar" )

{

print "! - Server A DEAD - !\n";

}

else

{

print "Server A checked.\n";

}

Sorry, aber einen Errorlevel hab ich noch nie gefunden... :rolleyes:

MfG

hm joa so wäre das doch ganz aktzeptabel wenn das funtzt naja nachher mal testen... :marine danke schonmal...

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.