<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>script &#8211; Uroš Vovk</title>
	<atom:link href="https://www.urosvovk.com/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.urosvovk.com</link>
	<description>Uroš Vovk home page</description>
	<lastBuildDate>Tue, 03 Mar 2026 21:15:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Bandwidth usage report per IP address</title>
		<link>https://www.urosvovk.com/bandwidth-usage-report-per-ip-address/</link>
					<comments>https://www.urosvovk.com/bandwidth-usage-report-per-ip-address/#comments</comments>
		
		<dc:creator><![CDATA[Uroš]]></dc:creator>
		<pubDate>Fri, 01 Jun 2018 13:04:54 +0000</pubDate>
				<category><![CDATA[Linux Stuff]]></category>
		<category><![CDATA[Network Stuff]]></category>
		<category><![CDATA[accounting]]></category>
		<category><![CDATA[bandwidth usage]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mikrotik]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python 2.7]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[RouterOS]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sqlite3]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[traffic]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://www.urosvovk.com/?p=858</guid>

					<description><![CDATA[I created a simple python script for collecting data from mikrotik accounting (documetation) feature. Here is my &#8220;mik_collector.py&#8221; script: all you need to change is router_ip variable to match your router IP after that you can run this script simply with this command: python mik_collector.py this will collect data from mikrotik every 5 seconds and store &#8230; <a href="https://www.urosvovk.com/bandwidth-usage-report-per-ip-address/" class="more-link">Continue reading <span class="screen-reader-text">Bandwidth usage report per IP address</span></a>]]></description>
										<content:encoded><![CDATA[<p>I created a simple python script for collecting data from mikrotik accounting (<a href="https://wiki.mikrotik.com/wiki/Manual:IP/Accounting" target="_blank" rel="noopener">documetation</a>) feature.</p>
<p>Here is my &#8220;mik_collector.py&#8221; script:<br />
<script src="//pastebin.com/embed_js/xCYZ9Cf8"></script></p>
<p>all you need to change is <em><strong>router_ip</strong></em> variable to match your router IP</p>
<p>after that you can run this script simply with this command:</p>
<pre>python mik_collector.py</pre>
<p>this will collect data from mikrotik every 5 seconds and store it in data.db sqlite3 database in the same directory as the script is.</p>
<p>All you need to do at mikrotik side is to enable accounting feature:</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-861" src="http://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_1.png" alt="" width="395" height="314" srcset="https://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_1.png 395w, https://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_1-300x238.png 300w" sizes="(max-width: 395px) 100vw, 395px" /> <img decoding="async" class="aligncenter size-full wp-image-862" src="http://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_2.png" alt="" width="303" height="185" srcset="https://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_2.png 303w, https://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_2-300x183.png 300w" sizes="(max-width: 303px) 100vw, 303px" /> <img decoding="async" class="aligncenter size-full wp-image-863" src="http://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_3.png" alt="" width="272" height="136" /></p>
<p>If you want to analyze your collected data you can do it with sqlite3 command from Ubuntu command prompt:</p>
<pre>sqlite3 data.db "select * from sum_per_month order by month"</pre>
<p>like this:</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-864" src="http://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_4.png" alt="" width="704" height="420" srcset="https://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_4.png 704w, https://www.urosvovk.com/wp-content/uploads/2018/06/mik_acc_4-300x179.png 300w" sizes="auto, (max-width: 704px) 100vw, 704px" /></p>
<p>you can write your own queries, all data is stored in a table named accounting. You can share your query in the comments :)</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.urosvovk.com/bandwidth-usage-report-per-ip-address/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Send telegram messages from Mikrotik RouterOS</title>
		<link>https://www.urosvovk.com/send-telegram-messages-from-mikrotik-routeros/</link>
					<comments>https://www.urosvovk.com/send-telegram-messages-from-mikrotik-routeros/#comments</comments>
		
		<dc:creator><![CDATA[Uroš]]></dc:creator>
		<pubDate>Thu, 19 Oct 2017 12:03:58 +0000</pubDate>
				<category><![CDATA[Network Stuff]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[mikrotik]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[RouterOS]]></category>
		<category><![CDATA[script]]></category>
		<guid isPermaLink="false">http://www.urosvovk.com/?p=841</guid>

					<description><![CDATA[If you are here you probably already know what telegram is. If not you can read about it here. I created a simple script (SendToTelegram) that allows you to send messages to telegram: :global telegramMessage :local botid :local chatid set botid "sdfzgasf7126jwsd7a8s12&#62;" # &#60;- change this set chatid "21156423187" # &#60;- change this if ($telegramMessage &#8230; <a href="https://www.urosvovk.com/send-telegram-messages-from-mikrotik-routeros/" class="more-link">Continue reading <span class="screen-reader-text">Send telegram messages from Mikrotik RouterOS</span></a>]]></description>
										<content:encoded><![CDATA[<p>If you are here you probably already know what telegram is. If not you can read about it <a href="https://telegram.org/" target="_blank" rel="noopener">here</a>.</p>
<p>I created a simple script (SendToTelegram) that allows you to send messages to telegram:</p>
<pre>:global telegramMessage
:local botid
:local chatid

set botid "sdfzgasf7126jwsd7a8s12&gt;" # &lt;- change this
set chatid "21156423187"            # &lt;- change this

if ($telegramMessage != "") do={
   /tool fetch url="https://api.telegram.org/bot$botid/sendMessage\?chat_id=$chatid&amp;text=$telegramMessage" keep-result=no
   set telegramMessage ""
}</pre>
<h3>Usage:</h3>
<p>set your message to telegramMessage global variable</p>
<pre>global telegramMessage "Wolfy was here"</pre>
<p>run script</p>
<pre>/system script run SendToTelegram</pre>
<p>You can use this in combination with netwach:</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-845" src="http://www.urosvovk.com/wp-content/uploads/2017/10/mikrotik-telegram-example.png" alt="" width="445" height="269" srcset="https://www.urosvovk.com/wp-content/uploads/2017/10/mikrotik-telegram-example.png 445w, https://www.urosvovk.com/wp-content/uploads/2017/10/mikrotik-telegram-example-300x181.png 300w" sizes="auto, (max-width: 445px) 100vw, 445px" /></p>
<p>you should recieve a message to your telegram :)</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-851" src="http://www.urosvovk.com/wp-content/uploads/2017/10/telegram-example-01.png" alt="" width="607" height="221" srcset="https://www.urosvovk.com/wp-content/uploads/2017/10/telegram-example-01.png 607w, https://www.urosvovk.com/wp-content/uploads/2017/10/telegram-example-01-300x109.png 300w" sizes="auto, (max-width: 607px) 100vw, 607px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.urosvovk.com/send-telegram-messages-from-mikrotik-routeros/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Programatically change ports on Mikrotik RouterOS</title>
		<link>https://www.urosvovk.com/programatically-change-port-on-mikrotik-routeros/</link>
					<comments>https://www.urosvovk.com/programatically-change-port-on-mikrotik-routeros/#comments</comments>
		
		<dc:creator><![CDATA[Uroš]]></dc:creator>
		<pubDate>Thu, 05 Oct 2017 12:00:16 +0000</pubDate>
				<category><![CDATA[Network Stuff]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[mikrotik]]></category>
		<category><![CDATA[nat]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[RouterOS]]></category>
		<category><![CDATA[script]]></category>
		<guid isPermaLink="false">http://www.urosvovk.com/?p=815</guid>

					<description><![CDATA[I created a simple script, that can help you change ports on your Mikrotik router How to use in my script fill array with port aliases: :global PFVports {http="80";ssh="22";https="443";ftp=23}; add a comment to your NAT rule, that starts with &#8220;PFV_&#8221; and folows with port alias like that: Now run my script and it will automatically &#8230; <a href="https://www.urosvovk.com/programatically-change-port-on-mikrotik-routeros/" class="more-link">Continue reading <span class="screen-reader-text">Programatically change ports on Mikrotik RouterOS</span></a>]]></description>
										<content:encoded><![CDATA[<p>I created a simple script, that can help you change ports on your Mikrotik router</p>
<script src="//pastebin.com/embed_js/1ikQgUky"></script>
<h3>How to use</h3>
<p>in my script fill array with port aliases:</p>
<pre>:global PFVports {http="80";ssh="22";https="443";ftp=23};</pre>
<p>add a comment to your NAT rule, that starts with &#8220;<strong>PFV_</strong>&#8221; and folows with port alias like that:</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-825 size-full" src="http://www.urosvovk.com/wp-content/uploads/2017/10/asdasdfad8qw65e-e1507196876109.png" alt="" width="860" height="90" srcset="https://www.urosvovk.com/wp-content/uploads/2017/10/asdasdfad8qw65e-e1507196876109.png 860w, https://www.urosvovk.com/wp-content/uploads/2017/10/asdasdfad8qw65e-e1507196876109-300x31.png 300w, https://www.urosvovk.com/wp-content/uploads/2017/10/asdasdfad8qw65e-e1507196876109-768x80.png 768w" sizes="auto, (max-width: 860px) 100vw, 860px" /></p>
<p>Now run my script and it will automatically set dst-port to whatever you set (in script) http port value&#8230; in my example port 80.</p>
<p>Next time you need to change some ports, you don&#8217;t need to change one by one, just update PFVports array and re-run this script.</p>
<h4>Note:</h4>
<p>dst-port is just one of many things that can be changed with this script&#8230; it can be easily changed to do whatever you need.</p>
<p>Hope you like it :)</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.urosvovk.com/programatically-change-port-on-mikrotik-routeros/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>BGInfo &#8211; Script for Local IP, Public IP and ISP Name</title>
		<link>https://www.urosvovk.com/bginfo-local-ip-public-ip-and-isp-name/</link>
					<comments>https://www.urosvovk.com/bginfo-local-ip-public-ip-and-isp-name/#comments</comments>
		
		<dc:creator><![CDATA[Uroš]]></dc:creator>
		<pubDate>Thu, 23 Feb 2017 19:00:09 +0000</pubDate>
				<category><![CDATA[Windows Stuff]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[bginfo]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[system info]]></category>
		<category><![CDATA[visual basic]]></category>
		<category><![CDATA[wallpaper]]></category>
		<category><![CDATA[windows]]></category>
		<guid isPermaLink="false">http://www.urosvovk.com/?p=788</guid>

					<description><![CDATA[I recently created 3 scripts for BGInfo &#8230; If you need it, use it ;) Local IP.vbs I found this script at ardamis.com and adapted to my needs. I removed VMware local IP, because I don&#8217;t need it strMsg = "" strComputer = "." Set objWMIService = GetObject("winmgmts:" &#038; "{impersonationLevel=impersonate}!\\" &#038; strComputer &#038; "\root\cimv2") Set IPConfigSet = &#8230; <a href="https://www.urosvovk.com/bginfo-local-ip-public-ip-and-isp-name/" class="more-link">Continue reading <span class="screen-reader-text">BGInfo &#8211; Script for Local IP, Public IP and ISP Name</span></a>]]></description>
										<content:encoded><![CDATA[<p>I recently created 3 scripts for <a href="https://technet.microsoft.com/en-us/sysinternals/bginfo.aspx">BGInfo </a>&#8230; If you need it, use it ;)</p>
<h2>Local IP.vbs</h2>
<p>I found this script at <a href="https://ardamis.com/2012/07/28/a-vbscript-for-displaying-only-ipv4-addresses-with-bginfo/" target="_blank" rel="noopener">ardamis.com</a> and adapted to my needs. I removed VMware local IP, because I don&#8217;t need it</p>
<pre lang="vb">strMsg = ""
strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress,description from Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'")

For Each IPConfig in IPConfigSet
	If Not IsNull(IPConfig.IPAddress) Then
	For i = LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
		If Not Instr(IPConfig.IPAddress(i), ":") > 0 Then
			If InStr(1, IPConfig.description(i), "VMware") = 0 Then
				strMsg = strMsg & IPConfig.IPAddress(i)
				If i > 0 Then
					strMsg = strMsg & vbcrlf & VBTab
				End If
			End If
		End If
	Next
	End If
Next
Echo strMsg
</pre>
<h2>Public IP.vbs</h2>
<p>Based on script from <a href="https://www.howtogeek.com/school/sysinternals-pro/lesson7/" target="_blank" rel="noopener">howtogeek.com</a><br />
I&#8217;m retrieving my public IP from <a href="https://www.ipify.org/">ipify.org</a></p>
<pre lang="vb">Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "https://api.ipify.org", False
o.send
echo o.responseText
</pre>
<h2>ISP Name.vbs</h2>
<p>I&#8217;m using <a href="https://www.whoismyisp.org">whoismyisp.org</a> for this task</p>
<pre lang="vb">Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "https://www.whoismyisp.org", False
o.send
strid = o.responseText
Set myRegExp = New RegExp
With myRegExp
	.Pattern = "< p class=""isp"">(.*)< / p >" 'remove spaces before use :)
	.IgnoreCase = False
	.Global = False
End With
Set myMatches = myRegExp.Execute(strid)

Echo myMatches.Item(0).SubMatches(0)
</pre>
<p><strong>IMPORTANT:</strong><br />
<span style="color: #ff0000;">Because my regex contain HTML tags I added space between < and p. If you want to use my script remove this spaces!</span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.urosvovk.com/bginfo-local-ip-public-ip-and-isp-name/feed/</wfw:commentRss>
			<slash:comments>14</slash:comments>
		
		
			</item>
		<item>
		<title>Check log files with grep</title>
		<link>https://www.urosvovk.com/check-log-files-with-grep/</link>
		
		<dc:creator><![CDATA[Uroš]]></dc:creator>
		<pubDate>Fri, 21 Sep 2012 10:15:07 +0000</pubDate>
				<category><![CDATA[Linux Stuff]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[script]]></category>
		<guid isPermaLink="false">http://urosv.wordpress.com/?p=225</guid>

					<description><![CDATA[I sometime need to check some logs and I do this with this command: egrep -o "p1&#124;p2&#124;...&#124;pn" filename &#124; sort &#124; uniq -c Example: egrep -o "success&#124;error&#124;fail" test_file &#124; sort &#124; uniq -c Sample input: test started at 00:00 test delete fail test error test connect success test insert success test started at 00:00 test &#8230; <a href="https://www.urosvovk.com/check-log-files-with-grep/" class="more-link">Continue reading <span class="screen-reader-text">Check log files with grep</span></a>]]></description>
										<content:encoded><![CDATA[<p>I sometime need to check some logs and I do this with this command:</p>
<pre>egrep -o "p1|p2|...|pn" filename | sort | uniq -c</pre>
<h1>Example:</h1>
<pre>egrep -o "success|error|fail" test_file | sort | uniq -c</pre>
<h2>Sample input:</h2>
<pre>test started at 00:00
test delete fail
test error
test connect success
test insert success
test started at 00:00
test delete fail
test error
test connect success
test insert success
test started at 00:00
test delete  fail
test error
test connect success
test insert success
test started at 00:00
test delete  fail
test error
test connect success
test insert success</pre>
<h2>Sample output:</h2>
<pre>4 error
4 fail
8 success</pre>
<h1>How it works?</h1>
<p><span id="more-225"></span></p>
<pre>egrep -o "success|error|fail" test_file</pre>
<h3>From grep manual:</h3>
<p><strong>egrep</strong> &#8211; print lines matching a pattern<br />
<strong>-o</strong> &#8211; Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.</p>
<p><strong>&#8220;success|error|fail&#8221;</strong> &#8211; patterns<br />
<strong>test_file</strong> &#8211; input file</p>
<p>If we run only egrep -o &#8220;success|error|fail&#8221; test_file we get this:</p>
<pre>fail
error
success
success
fail
error
success
success
fail
error
success
success
fail
error
success
success</pre>
<p>next we need to send grep output to sort:</p>
<pre>| sort</pre>
<h3>From sort manual:</h3>
<p><strong>sort</strong> &#8211; sort lines of text files</p>
<p>After sort is completed we have this:</p>
<pre>error
error
error
error
fail
fail
fail
fail
success
success
success
success
success
success
success
success</pre>
<p>now we need to send sort output to uniq command:</p>
<pre>| uniq -c</pre>
<h3>From uniq manual:</h3>
<p><strong>uniq</strong> &#8211; report or omit repeated lines<br />
<strong>-c</strong> &#8211; prefix lines by the number of occurrences</p>
<p>After this, we have what we wanted:</p>
<pre>4 error
4 fail
8 success</pre>
<p>This is all for today. I hope that this will help you to check huge log files!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Power on/off script for Xen Running VMs on XenServer</title>
		<link>https://www.urosvovk.com/power-onoff-script-for-xen-running-vms-on-xenserver/</link>
					<comments>https://www.urosvovk.com/power-onoff-script-for-xen-running-vms-on-xenserver/#comments</comments>
		
		<dc:creator><![CDATA[Uroš]]></dc:creator>
		<pubDate>Mon, 20 Feb 2012 12:05:57 +0000</pubDate>
				<category><![CDATA[Linux Stuff]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[power off]]></category>
		<category><![CDATA[power on]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shutdown]]></category>
		<category><![CDATA[Virtual machines]]></category>
		<category><![CDATA[VM]]></category>
		<category><![CDATA[xenserver]]></category>
		<guid isPermaLink="false">http://urosv.wordpress.com/?p=153</guid>

					<description><![CDATA[Days ago I needed a script to power on/off my runing VMs on XenServer&#8230; In my case I needed this to power off VMs when my UPS is running on batery and later to power on when the power comes back. I was looking for a script that can do the job, but after a &#8230; <a href="https://www.urosvovk.com/power-onoff-script-for-xen-running-vms-on-xenserver/" class="more-link">Continue reading <span class="screen-reader-text">Power on/off script for Xen Running VMs on XenServer</span></a>]]></description>
										<content:encoded><![CDATA[<p>Days ago I needed a script to power on/off my runing VMs on XenServer&#8230; In my case I needed this to power off VMs when my UPS is running on batery and later to power on when the power comes back.</p>
<p>I was looking for a script that can do the job, but after a while I didn&#8217;t find anything usefull&#8230; so I made my own script&#8230;<br />
<span id="more-153"></span><br />
My idea was to create a list of all running VMs and power off this VMs. Later, when I need to power on this VMs (from the list) I just call the same script again and it turn on all my VMs that are on this list.</p>
<p>Here is my script (shutdown_xen_vm.sh):</p>
<pre>#!/bin/bash

PROGRAMPATH="/root/scr/shutdown_vm"
if [ -f $PROGRAMPATH/vm-list.txt ]
then
   #$PROGRAMPATH/vm-list.txt exist
   echo "Power on:"
   cat $PROGRAMPATH/vm-list.txt | xargs -I{} echo " - {}"
   cat $PROGRAMPATH/vm-list.txt | xargs -I{} xe vm-start vm={}
   echo "Done"
   rm $PROGRAMPATH/vm-list.txt
else
   #$PROGRAMPATH/vm-list.txt do not exist
   xe vm-list power-state=running | grep name-label | awk '{print $4}' | tac | head -n -1 &gt; $PROGRAMPATH/vm-list.txt
   echo "Power off:"
   cat $PROGRAMPATH/vm-list.txt | xargs -I{} echo " - {}"
   cat $PROGRAMPATH/vm-list.txt | xargs -I{} xe vm-shutdown vm={}
   echo "Done"
   echo "Shutdown xen server..."
   shutdown -P now
fi</pre>
<h2>How it works:</h2>
<p>check if file vm-list.txt exist</p>
<pre>   if [ -f $PROGRAMPATH/vm-list.txt ]</pre>
<p>Just print a list of all VMs that were powered off</p>
<pre>   echo "Power on:"
   cat $PROGRAMPATH/vm-list.txt | xargs -I{} echo " - {}"</pre>
<p>Start all VMs from the list and delete this list</p>
<pre>   cat $PROGRAMPATH/vm-list.txt | xargs -I{} xe vm-start vm={}
   echo "Done"
   rm $PROGRAMPATH/vm-list.txt</pre>
<p>Get all running VMs and write it to vm-list.txt</p>
<pre>xe vm-list power-state=running | grep name-label | awk '{print $4}' | tac | head -n -1 &gt; /root/scr/shutdown_vm/vm-list.txt</pre>
<p>Just print a list of all VMs that will be powered off</p>
<pre>   echo "Power off:"
   cat $PROGRAMPATH/vm-list.txt | xargs -I{} echo " - {}"</pre>
<p>Power off VMs from the list and shutdown XenServer</p>
<pre>   
   cat $PROGRAMPATH/vm-list.txt | xargs -I{} xe vm-shutdown vm={}
   echo "Done"
   echo "Shutdown xen server..."
   shutdown -P now</pre>
<p>Now, to run this script you just need to do this:</p>
<pre>   
chmod +x shutdown_xen_vm.sh
./shutdown_xen_vm.sh</pre>
<p>&#8212;</p>
<p>I hope that this script will help you as it helped me :)</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.urosvovk.com/power-onoff-script-for-xen-running-vms-on-xenserver/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
