User:Rsepp: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 39: | Line 39: | ||
import sys,os | import sys,os | ||
#Etteantud parameetrite kontroll | #Etteantud parameetrite kontroll | ||
Line 57: | Line 52: | ||
found = False | found = False | ||
for line in fh: | for line in fh: | ||
if IP in line: | if "address " + IP in line: | ||
found = True | found = True | ||
break | break | ||
Line 66: | Line 61: | ||
print "Alias puudub" | print "Alias puudub" | ||
sys.exit(1) | sys.exit(1) | ||
</source> | |||
<source lang="powershell"> | |||
#Autor: Rene Sepp A21, rsepp@itcollege.ee | |||
#Versioon: 0.1 | |||
#Skript, mis Disableb/Enableb Wifi adapteri. | |||
#Leiame Wireless adapteri | |||
$adapter = Get-WmiObject -Class Win32_NetworkAdapter | Where {$_.Name -like "*Wireless*"} | |||
#Disableb Wireless adapteri | |||
$adapter.Disable() | |||
sleep(1) | |||
$adapter = Get-WmiObject -Class Win32_NetworkAdapter | Where {$_.Name -like "*Wireless*"} | |||
#Kontrollib error koodi | |||
if($adapter.ConfigManagerErrorCode -eq 22){ | |||
Write-Host "Wifi adapter on Disabled olekus" | |||
} | |||
#Enableb Wireless adapteri | |||
$adapter.Enable() | |||
sleep(1) | |||
$adapter = Get-WmiObject -Class Win32_NetworkAdapter | Where {$_.Name -like "*Wireless*"} | |||
#kontrollib error koodi | |||
if($adapter.ConfigManagerErrorCode -eq 0){ | |||
Write-Host "Wifi adapter on Enabled olekus" | |||
} | |||
#Salvestab kuupäeva faili adapter.txt | |||
Get-Date | Out-file C:\adapter.txt -append | |||
</source> | </source> |
Latest revision as of 19:11, 30 May 2011
#!/bin/bash
#Autor: Rene Sepp A21
#Skript kontrollib, kas Ubuntu serveris on seadistatud etteantud IP alias
IP=$1
#Õiguste kontroll
if [ $UID -ne 0 ]; then
echo "Käivita skript $(basename $0) rootkasutaja õigustega"
exit 1
fi
#Kontrollib kas IP on parameetrina antud
if [ $# -ne 1 ]; then
echo "Käivita skript $(basename $0) koos IP-ga"
exit 1
fi
#Otsib failist '/etc/network/interfaces' argumendis antud IP vastet ja võrdleb seda argumendis antud IP-ga
if [ $IP = $(grep $IP '/etc/network/interfaces' | cut -d"s" -f3 | cut -d" " -f2 | sort -u) ]; then
echo "alias olemas"
exit 0
else
echo "aliast pole"
exit 1
fi
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Autor: Rene Sepp A21
#Versioon: 0.1
#Skript kontrollib, kas Ubuntu serveris on seadistatud etteantud IP alias
#Kasutamine: alias.py <IP>
import sys,os
#Etteantud parameetrite kontroll
if len(sys.argv) != 2:
print "Käivita skript %s parameetritega : koos IP-ga"
sys.exit(1)
IP = (sys.argv[1])
fh=file("/etc/network/interfaces")
found = False
for line in fh:
if "address " + IP in line:
found = True
break
if found == True:
print "Alias olemas"
sys.exit(0)
else:
print "Alias puudub"
sys.exit(1)
#Autor: Rene Sepp A21, rsepp@itcollege.ee
#Versioon: 0.1
#Skript, mis Disableb/Enableb Wifi adapteri.
#Leiame Wireless adapteri
$adapter = Get-WmiObject -Class Win32_NetworkAdapter | Where {$_.Name -like "*Wireless*"}
#Disableb Wireless adapteri
$adapter.Disable()
sleep(1)
$adapter = Get-WmiObject -Class Win32_NetworkAdapter | Where {$_.Name -like "*Wireless*"}
#Kontrollib error koodi
if($adapter.ConfigManagerErrorCode -eq 22){
Write-Host "Wifi adapter on Disabled olekus"
}
#Enableb Wireless adapteri
$adapter.Enable()
sleep(1)
$adapter = Get-WmiObject -Class Win32_NetworkAdapter | Where {$_.Name -like "*Wireless*"}
#kontrollib error koodi
if($adapter.ConfigManagerErrorCode -eq 0){
Write-Host "Wifi adapter on Enabled olekus"
}
#Salvestab kuupäeva faili adapter.txt
Get-Date | Out-file C:\adapter.txt -append