How to get a Snapshot report from AWS using Python..

I was not sure if I was making a mistake by leaving Micron for a job in a small company. Anyway I don’t regret the move. In fact I actually love this job so far. It has all the good and bad things of working in a small company. Things are messy there. But.. the opportunity to learn and perform are tremendous, and that is what I really was looking for.

I was asked to modify a python script written by an ex-employee to get the snapshot report from AWS. I have never touched python for at least 5 years, and even then, that was all about simple things. And my experience with AWS SDK were none. So when I looked at the code, I did not understand anything. So I decided to do it myself from scratch instead of modifying it.

You can find the script here.

Basically, it collects the access and secret keys as arguments, then connect to ec2, get all the running instances, then the volumes attached to it, and then the snapshots. I have no idea if it is the best way to do it. I don’t even think that I used the best python practices.  Anyway, it works well now. Once the script is executed, it will create a nice csv file as follows, which is great. It has all the fields, and it is easy to manipulate in a spreadsheet according to our needs.Snapshots

This saves us a  lot of time from checking manually for each of our customer accounts if the snapshots are there or not.

I feel pretty proud about this. You know, no matter how bad  the code is, it works. 😉



My experience with RHCE and RHCSA exams

In one word, I can say the following:

RHCSA – Easy

RHCE – Doable

Although I have been using desktop linux , particularly Ubuntu for a while, I never had a chance to do proper system administration. So in a way, I was a fresher. One advantage I had was that I had some domain knowledge on how all these things works, and some things in general. So the terms were not aliens to me.

For exam prep, I did an online course by IPSR, a training institute from India. They claims to have produced the most number of Red Hat professionals in the world. One thing that I can assure is that their training is good. Even if the course is not taken, it is really good to do mock exams using their practice papers.

Coming to the exams, they follow a pattern. RHCSA was 2.5 hours exam, but they were following an exactly similar pattern of questions as that from IPSR’s practice papers. Once you are familiarized with these questions, it is almost 100% chance to pass this exam. In fact, there are people who learn these answers by-heart and pass the exam. There are a lot of model questions that I found online, but most of them wont help for this exam ( They help for real life situations for sure ). I managed to complete the exam in just over an hour, and managed to score 294 out of 300.

Verdict : Simple

For RHCE also, the questions follow a pattern. IPSR’s questions help us familiarize with them too. But unlike RHCSA, the content is huge, and you cant just pass by learning them by heart. You really need to understand the concepts and learn how to apply them. Its a 3.5 hours exam, and it will take you at least 3 hours to finish all.

In my case, I was really confident on the exam, and started doing well. At around 2.5 hour point, I had completed 2/3rd of the questions. But for the next question, I did a huge mistake and messed up the whole partition in my server machine. It was not able to boot up, so I had to start from scratch at that point. My client was still there, so I had to redo everything that I did in the server again. I only managed to reach the 2/3rd point by the end of 3.5 hours.

I thought I would fail, but when the result came, I passed with 232 out of 300. I think it is good to say that dont attempt the question if you dont know. It is better to leave it there rather than messing it up.

Verdict : Doable, but need to do proper time management, and should have enough knowledge on commands and how to read through man pages.

I did the exams on Dec 2016

How to display a pop up message in a remote computer using powershell

In my daily work, there are times which I need to contact a user who is using a particular PC, but they don’t respond. Mostly, I need to contact them to inform about something, or get them to reboot, or install something etc. There are some cases which it is not possible, such as :

  • They use a generic account which is shared, so we can’t find who exactly is using that PC
  • They are logged off from IM
  • They don’t respond to IM or just ignore them.

In these kind of cases, it is easier if we have some way to forcefully push a message to the PC. I found an easy solution from internet that can do this in every computer that you have admin access.

Open a text editor and add the following in it, then save it with .ps1 extension.

Function remote_message{

$server = read-host -prompt ‘Input PC name’;
$message = read-host -prompt ‘Enter the message’;

Invoke-WmiMethod -Class win32_process -ComputerName $server -Name create -ArgumentList  “c:\windows\system32\msg.exe * $message” }


To run this, open powershell, then navigate to the saved location and run. And follow the input prompt.


No matter who is logged in the remote PC, they will get the message pop up on top of all their windows.



How to remove UAC prompt for a software in Windows

[This was originally published in my another blog on July 2016.]
Today I received a support request from a user who is facing issues while running a macro script. He was facing Run-time error 429 : ActiveX Component cannot create object.

Though I have never written macro, I decided to give a try. When clicked the debug button I got the following message.

OK. Data navigator is an internal software that we use for pulling some data. This message showed that this error has something to do with the Data Navigator. Its installed properly and is working fine when opening. However when compared to another PC which has no issue in running the script, found a small difference, there is a UAC Prompt in this PC when opening the software.
I am not sure why in some PCs it has this prompt while others not. Anyway I decided to find a way to remove this prompt and try again.

A quick google search brought me here.

Following the instructions, I downloaded and installed Microsoft application Compatibility toolkit. Once done, you will see 32 and 64 bit versions.

Take note that even if you have a 64 bit OS, the 64 bit version can only be used for 64 bit software. For my case, I have a 64 bit OS, but the data navigator is a 32 bit software.

Once opened the software, click on the Fix button.

Enter the necessary information.
Click Next and select the RunAsInvoker checkbox.
Click the Test Run button to make sure that there is no prompt when opening the mentioned software.

Click Next and make sure that the RunAsInvoker is checked there also.

Click Next, followed by Auto Generate from the next screen.
Click Finish

Now, we need to save the database. For that, click the Save button, and give the database a name.
Provide the save location when prompted.

Click on File, and then Install the database.
Now, click OK and close the Compatibility Administrator. Go to the Start menu and right-click your application, select properties and select the Advanced button. Make sure that  Run as administrator checkbox is cleared. Click OK.
Now click the Compatibility tab, then Change settings for all users and tick the Run this program as an administrator checkbox.
VOILA !! We are done.

This made the macro to run properly, and made my user really happy. I hope this helps you all too.

How to use your Raspberry pi to download movies automatically


  • This is for educational purposes only. Do everything at your own risk. Using bit torrent is not illegal, but downloading copyrighted materials are.
  • Do not use this in a production environment. We are considering zero security in this case.


I see that this post gets a lot of attention. If this works/doesn’t work please let me know in the comment section, or email me at

What we are going to build:

An always on torrent box that periodically checks for new torrents as defined and download them.

What we will be using:

•    Raspberry pi 3 model b with Raspbian Jessie installed.
•    Official raspberry pi 3 PSU as third party PSU’s may not provide enough power
•    External HDD
•    USB fan or heatsink (Recommended, not necessary)

mysetupmy current setup


•    You have vnc / physical access with GUI to your pi
•    You have a user named pi with sudo access (this available by default)
•    You know the password of user pi

Note: We will be doing most of the configurations in a terminal.

1) Install and enable apache webserver
This will help to access the contents over a webserver. Install it by typing

sudo apt-get install apache2

Once installed, start and enable it

sudo systemctl enable apache2
sudo systemctl start apache2

Give everyone full permission to the documentroot. [This is not safe at all in  a production environment.]

sudo chmod 777 /var/www/html

2) Connect the hard disk, create mountpoint and setup automount

•    Connect your hard disk to the pi. Make sure that it works by accessing the contents. If you see a lightning bolt symbol on the top right corner of the screen, that means the pi is not getting enough power to work properly. Use the official PSU in this case.
•    Open a terminal, and see where the hard disk is mounted, by using the following command




In this case, it is mounted in /var/www/html. This will not be your case. It will probably in something like /media/pi/xxx . Whatever it is take note of it. Let us call this value as initial_mount_point

•    Get the block id of the hard disk. Take note of the value starting from UUID


•    Configure fstab so that the hard disk will mount to a certain point after reboot

sudo nano /etc/fstab

• This will open the fstab file in nano text editor in the terminal. Navigate to the end of the line, and type the following

UUID=”xxxxxxxx” /var/www/html ntfs defaults 0 0

Where “xxxxx” is the block id that you got from the previous step.


Type CTRL+O to save and CTRL+X to exit the editor.

•    Unmount the hard disk from initial mount point

sudo umount initial_mount_point

where initial_mount_point is what you got from the first step, which is something like /media/pi/xxxx • Now mount the hard disk to the new mount point.

sudo mount –a

• Verify that it worked by typing the df command. You should get output like this.


3) Install and configure flexget

Felxget will be the tool that we use to download torrent files based on our preferences. The following information is from their website.(
•    Python
FlexGet requires Python 2.7, 3.3 or newer to run. You can check your version with command.

python -V

If it is not available, install it by using the following command in terminal

sudo apt-get install python3.5


Second piece of required software is python package manager called PIP. This can be usually found from operating system package repository under name python-pip or python3-pip. If you install python3-pip it may need to be used via command pip-3.5 or something similar.
Install it by using the following command
sudo apt-get install python-pip5

• Upgrade setuptools

Using latest setuptools will save headaches in some older installations, this can be achieved with
sudo pip install --upgrade setuptools

• Install in a virtualenv

This is the recommended way unless you want multiple accounts in the system to be able to use FlexGet without each having to install it themselves.

Install virtualenv:

sudo pip install virtualenv

Create Virtualenv: This creates isolated python environment. You can create as many of these as you like for each python application you use.

virtualenv ~/flexget/

Install FlexGet in the virtualenv:

cd ~/flexget/
bin/pip install flexget

Create a folder to save the torrent files that are downloaded.

sudo mkdir /home/torrents
sudo chmod 777 /home/torrents

Configure flexget to download torrents automatically

This is the most important and confusing part. Here I am sharing only what I did and found to be working. You can find many other configurations from here and here.

We will configure only to download new Malayalam movies published in , English movies published in and new episodes of Sherlock from anywhere.

To do that,
Navigate to the install directory

cd ~/flexget

Create a configuration file using nano editor

nano config.yml

Type the following:

  Download Sherlock:
      – Sherlock
        – 720p
    download: /home/torrents/
  Download movies:
        – DVDRip
        – cam
        – 2GB
    download: /home/torrents/
  Download english movies:
        – yts
    download: /home/torrents/



CTRL+O and CTRL+X to save and exit

Instead of typing the above, you may download my config file from here.

•    Test the configuration
Navigate to the flexget install folder and make it executable

cd ~/flexget/bin
sudo chmod +x flexget

Test the configuration by following command:

./flexget --test execute

If your output is similar to the following, there is something wrong with your config.


If everything is OK, you will get something like this:


Now let us execute flexget to download the torrent files.

./flexget execute

This will download the torrent files to the folder we created earlier, to /home/torrents. Let us verify

ls /home/torrents


There will be a lot of .torrent files. Mine has that .added name because all of them are already completed downloading.

4) Install and configure transmission to download the files using the torrent files already downloaded.

sudo apt-get install transmission-gtk

Open transmission from the start menu


Go to edit-preferences, Set the speed limits you want from Speed tab


In the downloading tab,


In automatically add .torrent files from, select /home/torrents folder Untick show the Torrent Options Dialog Tick Start added torrents In Save to Location, navigate to your hard disk mount point, which is /var/www/html and select the folder you want.


You can leave the other settings as it is, or change it if you need. Now wait a few minutes and you can see that the torrents start downloading.

5) Configure flexget to check for torrents periodically

We will setup flexget to check for new torrents every hour and download it if found. For that, we will use crontab, which is pre installed in the system.

Open crontab by following command:

crontab –e

This will open the crontab file in a text editor. Navigate to the end and add the following lines:

# to run flexget without generating log files
20 * * * *  /home/pi/flexget/bin/./flexget execute

# start transmission-gtk version minimized if it is not already running
*/30 * * * * export DISPLAY=:0 && if pidof -x /usr/bin/transmission-gtk; then exit; else /usr/bin/transmission-gtk -m; fi &

CTRL+O and CTRL+X to save and exit

By now, you have your pi configured to check for new torrents every hour and download it to the hard disk connected to it. In the following steps, we will make it accessible via a web browser or as a network drive.

6) Configure a static ip address to the pi

sudo nano /etc/dhcpcd.conf

Go to the end of the file and add the following:

interface eth0

static ip_address=
static routers=
static domain_name_servers=

interface wlan0

static ip_address=
static routers=
static domain_name_servers=

Here, you need edit based on your needs. My router address is and I set my ip to be


7) Configure apache web server.

We will use the default configuration settings here. To verify it,

sudo  nano /etc/apache2/sites-enabled/000-default.conf

Just make sure that the DocumentRoot is set to be /var/www/html. If it is not, edit it. Mostly there is no need to edit.


Restart the web server

sudo systemctl restart apache2

Verify that it works by going to the webpage from a browser. Note that this device should be connected to your home network. You should be able to access the hard disk contents now.

You will be able to watch videos from your browser.


8) Install and configure samba for using as a network drive

sudo apt-get install samba
sudo nano /etc/samba/smb.conf

This will open samba configuration file in nano. Go to the end of the file and type the following, and save and exit.

  path = /var/www/html/
  public = yes
  read only = yes
  guest ok = yes
  browseable = yes


Enable and restart samba.

sudo systemctl enable smbd
sudo systemctl restart smbd

Now you can map this as a network drive in your windows PC. To do this in windows 10, right click My PC, then click Map network drive.


Enter the ip address and share name as follows. Share name is movies as we configured earlier. Check connect using different credentials. Enter username as pi and the password to connect.


You should have it connected as a drive now.