Coding / Scripts

1.0

PHP/SNMP and MAC addresses

0

That scripts allow you to enter all MAC adresses informations into a database and then run whatever you like to that DB to make it throw up what you need.

(more…)

1.0

Creating images from a string in PHP

0

This code snippet allow you to create an image from any string in PHP. There’s many implications where that could be useful, in my case it was to prevent copy/pasting of some text.

This code allow you to enter a string and submit it to the code and then receive the link to the images, you should be able to do the rest on your own!
(more…)

1.0

Éteindre tous les ordinateurs d’un réseau

0

Question de sauver de l’électricité, il est une bonne idée d’implanter un script semblable pour éteindre tous les postes de votre réseau le soir quand tout le monde à quitté le bureau. Voici donc un petit script Bash qui roule sous n’importe quel serveur Linux.

#!/bin/bash
 
EXEMPTION_ARRAY=( 192.168.102.122 192.168.102.197 192.168.102.156 192.168.102.47 )
 
echo "THIS PROGRAM WILL SHUTDOWN ALL THE PCs IN THE NETWORK, PRESS CTRL+C TO EXIT, YOUVE 10 SECONDS"
 
sleep 10
 
echo "ARE YOU SURE YOU WANT THIS SCRIPT TO SHUTDOWN ALL THE PCs! YOUVE 5 SECONDES BEFORE BOMB PRESS CTRL+C TO STOP ME"
 
sleep 5
 
for IP in $(nmap -sP 192.168.101-103.* | grep ") appears to be up." | awk '{print $3}'); do
 
EXEMPT=false
 
IP2=${IP%%)}
IP3=${IP2##*(}
 
for check_exempt in ${EXEMPTION_ARRAY[@]}; do
	if [ "$check_exempt" = "$IP3" ]; then
		EXEMPT=true
	fi
done
 
if [ "$EXEMPT" = "true" ]; then
	echo $IP3 est exempte
else 
	/usr/bin/net rpc SHUTDOWN -f -I $IP3 -U 'username%password' -t 120
fi
 
done

Le script demande l’utilisation de nMap pour scanner le réseau pour les ordinateurs encore allumés.

Go to Top