Category Archives: Bez kategorii

MikroTik – copy DHCP leases to ARP script

Poniższy skrypt kopiuje wpisy DHCP leases (powiącania IP – MAC) do tablicy ARP.

#Define interface that clients are connected to. In my case bridge1
:local interface bridge1;

#Deleting old ARP entries
#Adding information to log
:log info ("Deleting old ARP entries");
:foreach arpId in=[/ip arp find] do={
	/ip arp remove $arpId;	
}

#Adding new ARP entries
:foreach leaseId in=[/ip dhcp-server lease find] do={

	#OPTIONAL - copy DHCP Lease comment to leaseComment variable
	#:local leaseComment  [/ip dhcp-server lease get $leaseId comment];
	
	#copy DHCP Lease IP address to leaseMAC variable 
	:local leaseIP [/ip dhcp-server lease get $leaseId address];
	
	#copy DHCP Lease MAC address to leaseMAC variable 
	:local leaseMAC  [/ip dhcp-server lease get $leaseId mac-address];	
	
	#Adding new ARP entries
	/ip arp add address=$leaseIP mac-address=$leaseMAC interface=$interface disabled=no published=no;
	
	#Adding information to log
	:log info ("Adding new ARP entry");
}

Handbrake – automatyczna kompresja plików video

Poniższy skrypt PowerShell umożliwia automatyczną kompresję materiałów video w folderze i podfolderach.

gci . *.mp4 -R | 
foreach-object {
 $saveBase = "v:\handbrake"
 $curDir = (Get-Item -Path ".\" -Verbose).FullName
 $inName = $_.BaseName + $_.Extension
 $inFile = $_.DirectoryName + "\" + $inName
 $outFile = $saveBase + $inFile.replace($curDir, "")
 $outDir = $outFile.replace($inName, "")
 New-Item -path "$outDir" -type directory -force
 echo "Working on $inFile"
 echo "Saving to $outFile"
 &"C:\Program Files\HandBrake\HandBrakeCLI.exe" -i "$inFile" -o "$outFile" --preset "Very Fast 1080p30"
}

Źródła i inne tematycznie związane artykuły:
http://www.codegist.net/search/handbrake%20recursive%20encode/1
https://dzone.com/articles/poor-mans-batch-encoding-with-handbrake
https://www.hanselman.com/blog/BatchConvertingADirectoryTreeOfVideosRecursivelyWithHandbrakeForStreamingToAnXbox360.aspx
https://jorge.fbarr.net/2012/05/19/batch-convert-videos-using-handbrake-and-a-script/

VirtualBox – zapisanie stanu maszyny

Poniżej przedstawiony jest skrypt zamykający maszyny wirtualne a następnie zamykający hosta (system Windows).

"C:\VirtualBox\VBoxManage.exe" controlvm "Ubuntu Server" savestate
"C:\VirtualBox\VBoxManage.exe" controlvm "Ubuntu Minimal" savestate
shutdown /s /t 10