User:Rsepp: Difference between revisions
From ICO wiki
Jump to navigationJump to search
Created page with '<source lang="bash"> #!/bin/bash #Autor: Rene Sepp A21 #Skript kontrollib, kas Ubuntu serveris on seadistatud etteantud IP alias IP=$1 #Õiguste kontroll if [ $UID -ne 0 ]; the…' |
No edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
fi | fi | ||
# | #Kontrollib kas IP on parameetrina antud | ||
if [ $# -ne 1 ]; then | if [ $# -ne 1 ]; then | ||
echo "Käivita skript $(basename $0) koos | echo "Käivita skript $(basename $0) koos IP-ga" | ||
exit 1 | exit 1 | ||
fi | fi | ||
Line 27: | Line 27: | ||
exit 1 | exit 1 | ||
fi | fi | ||
</source> | |||
<source lang="python"> | |||
#!/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) | |||
</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> |
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