Recursive batch Script to get latest/static file name – SyedTips – 7

If you followed my earlier tip, notice how I always passed in Image.png as an image file into tesseract to get a text value? This is totally fine if you can source static Image files and make sure they are available at a particular location.

However, what if you’re using a live camera that saves a stream of Images? I used mjpg-streamer to live stream images on a web browser and also save them on a Raspberry Pi.

Following is the bash command that captures images from a USB WebCam and streams it over:

./mjpg_streamer -i "./ -r 640x480 -f 1" -o "./ -w /usr/local/www" -o "./ -f /home/pi/Camera_Output -c /usr/bin/"

The above command does the following 3 things:

  1. Stream Images over the Web/Browser
  2. Save Images to a local folder on the Raspberry Pi
  3. Invoke a custom Script

Here’s how the local folder containing the saved streamed image files looks like:


Now here’s the challenge: Firstly, tesseract can only take in a defined fileName as an argument and since we’re invoking tesseract from Python, we can’t simply use a script to get the latest file name and pass it as a parameter.

So here’s what I did to solve this: Get the latest file and rename it to Image.png in that same folder. So at any instance, the latest captured image file is always Image.png. Now, simply pass this as an argument into tesseract and all’s done 🙂

I used the following code snippet to get latest file pointed as Image.png:

# move the temporary file to a given filename
cd /home/pi/syed

cp -f -T `find -type f -name '2015*' -printf "%C@\t%P\n" |sort -r -k1,1 |head -1 |cut -f 2-` /home/pi/syed/Image.png

I saved this snippet into which is being invoked on every Image capture as shown earlier.

P.S: A more detailed script that shows debug messages:


# comment out the following line to disable messages

if [ $VERBOSE ]; then
  echo -e "Rename script started at:\t$(date)";
  echo -e "Parameter \$1 is:\t\t$1"
  echo -e "current directory is:\t\t$(pwd)"
  echo -e "move command is:\t\tmv -T -f \"$1\" 'Image.jpg'"

# move the temporary file to a given filename
cd /home/pi/syed
cp -f -T `find -type f -name '2015*' -printf "%C@\t%P\n" |sort -r -k1,1 |head -1 |cut -f 2-` /home/pi/syed/Image.png

if [ $VERBOSE ]; then
  echo -e "move command returned:\t\t$RES"

Thanks 🙂


Invoking Shell commands from Python – SyedTips – 6

While building an ALPR (Automatic License Plate Recognition) System on a Raspberry Pi in 2013, I came across tesseract  which is a very powerful OCR (Optical Character Recognition) tool.

Tesseract is a command line tool which means it has to be invoked as a command from the shell/terminal (and it works on both Windows and *nix):

tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfiles...]

Since my main image capture and trim script was based on Python (triggered from a WebPage), I had to find a way to invoke tesseract from within Python. At first, I looked out for python libraries and wrappers of tesseract and had a hard time getting them to run on the Raspberry Pi.

Eventually, I wondered if there was a way to invoke shell commands from Python; and yeah!

Using subprocess, you can do just that:

import subprocess["tesseract", "/home/pi/syed/Image.png", "/home/pi/OpenCV/OCR_Data"])

Pass each argument to the invoked command separated with , in “”


Buying Raspberry Pi 2 in India, Hyderabad

I get most of my Raspberry Pi and related stuff from PotentialLabs (where I also consult on Tech stuff). If you guys are looking at buying the Raspberry Pi 2 at a reasonable price, you can buy it off from here: Continue reading “Buying Raspberry Pi 2 in India, Hyderabad”

Sharing WiFi Internet connection with Raspberry Pi through LAN/Ethernet (Headless Mode)

Update 25th August, 2017: I haven’t tried this method yet on the recently released Raspbian Stretch version. However, one user has confirmed that the first method works on it. If it works for you, please let us know through the comments. Thanks.

Update 29th Dec, 2016: If you’re using the latest PIXEL Image, please make sure you enable the SSH Server by placing a a file named as ssh in the boot directory before trying any of the following methods. The SSH Server on boot has been disabled in the latest Raspbian image as a security measure. Read more about it here:

Update 9th July, 2016: I’m inspired by this method of SSHing into a Pi through the USB only and gonna tinker and see if we can get to also share Internet over to the Pi using only the USB. (No more messy LAN Cable 🙂 ). If you get it working, please share.

Update 10th July, 2016: I’m afraid, I won’t be able to get the above method running on a Pi 2/3 as it’s only supposed to work on a Pi Zero. If you have a Pi Zero and are interested in Sharing WiFi over USB, please check out

Updated 5th April, 2016 with Striner’s method


If this Tutorial helps you, please consider PayPaling me any positive integer at

This post will allow you to share WiFi Internet connection of the PC/Laptop with the Raspberry Pi which are connected to each other through a simple LAN/Ethernet cable connection at each end.

What you want to do:

  1. Share PC/Laptop’s WiFi Internet connection with Raspberry Pi through LAN/Ethernet connected to Raspberry Pi

Continue reading “Sharing WiFi Internet connection with Raspberry Pi through LAN/Ethernet (Headless Mode)”

Direct Access Raspberry Pi Shell and Desktop on Laptop/PC without installing anything on the Raspberry Pi OS or connecting it to a Display Unit

Update 15th Sept, 2017: The easiest way to get this running on a Raspberry Pi Zero W is outlined here: where you’d only need an available WiFi connection. If you don’t have a WiFi connection, use your dumbPhone and setup a WiFi Hotspot. This is much easier than using a USB-Ethernet Adapter and then following the following methods.

Update 29th Dec, 2016: If you’re using the latest PIXEL Image, please make sure you enable the SSH Server by placing a a file named as ssh in the boot directory before trying any of the following methods. The SSH Server on boot has been disabled in the latest Raspbian image as a security measure. Read more about it here:

Before you go neck-deep into this post, please check if this post is applicable for you:

What you want to do:

  1. Access Raspberry Pi’s desktop on Laptop/PC screen

What you have:

  1. Raspberry Pi A+/B/B+/Pi 2 (If you’ve a Pi Zero, please try and let us know if this works on a Zero. Not tested with a Pi 3 either) running the latest Raspbian Wheezy (I’ve not yet tried it with recently released Raspbian Jessie based off Debian 8. If you’ve been successful with this latest release, please post in the comment and I’ll update it here. Thanks.)
  2. Laptop (Windows 7 or XP with Internet connection, required to download one setup file)
  3. A working SSH connection with Raspberry Pi (direct access, explained below)

What you don’t have (and not required):

  1. Display Device for the Raspberry Pi (HDMI enabled display unit / Old TV)
  2. Internet connection for the Raspberry Pi (LAN or WiFi)

Extra Stuff you need:

  1. Standard Network Cable (Cat 5, Standard or Crossover)
  2. PutTTY Software (will be used to SSH into the Pi)
  3. SD Card Writer

Continue reading “Direct Access Raspberry Pi Shell and Desktop on Laptop/PC without installing anything on the Raspberry Pi OS or connecting it to a Display Unit”

Buying Raspberry Pi Online in India

There are now a couple of stores brewing around from where you can buy the Raspberry Pi online in India. Many of these stores also stock getting started kits and other accessories.

Since, I’m based out of Hyderabad, I’d like to recommend PotentialLabs for buying Raspberry Pi if you’re based in Hyderabad, Telangana/Andhra Pradesh. Buy from my MakerStore at We ship same day or you can also pick up from our Brick and Mortar store.

Other prominent stores where I have purchased include:

Simple Labs –

Explore Labs –

MG Super Labs –

There are tonnes of other stores, but I’ve had a nice experience with the above ones.


Internet of Things framework for the Raspberry Pi

For a start, one of the primary reasons for me to start a blog was to share those many links which otherwise I’d bookmark and lose track of them when I actually needed something. Secondly, I make notes in many mediums and maintaining and indexing them all was getting troublesome as newere content was being added. Plus, sharing something on the web is a million times better than holding out stuff within self. 🙂

Now, this is awesome!!!

Internet of Things framework for the Raspberry Pi

Control, debug, and use your Pi’s GPIO locally or remotely, from a browser or any app

WebIOPi is the perfect Swiss-knife to make connected things with the Raspberry Pi

Developed and provided by Eric PTAK (aka trouch)


  • REST API over HTTP and CoAP (draft-14) with multicast support
  • Server written in Python with zero dependency
  • Supports GPIO, Serial, I2C, SPI, 1-Wire with zero dependency
  • Supports more than 30 devices including DAC, ADC, sensors…
  • Full Python library for the Server, GPIO, Serial, I2C, SPI and devices drivers
  • Compatible with both Python 2 and 3
  • Extensible and highly customizable
  • Login/Password protection
  • Mobile devices compatible
  • Includes debug web apps
  • GPIO Header
  • GPIO List
  • Serial Monitor
  • Devices Monitor

Javascript client library built on top of jQuery

Python client library with HTTP and CoAP support More information on


NOOBS introduced for RasPi

If downloading an Image, formatting it on a SD card and booting the image off the Pi wasn’t already easier, folks from the RasPi have come up with NOOBS for the RPi NOOBS 🙂

A single file (approx 1GB) that you now need to install on a freshly formatted SD card. After plugging it in the Pi and powering it up, it’ll present you with sleek bootup options including the choice to install one of the several operating systems into the SD card. And Voila, you’ve a RPi up and running.

A good feature that I liked about this app is it allows you to edit the config.txt and cmdline.txt by holding the Shift button on reboot.

To download and read more about this, head on to:


Using Raspberry Pi as an AVR Programmer

Cool things are getting revealed as days progress and folks crank out every single byte RAM from that mean power machine. Here we’ve come across an awesome project where a Pi is being used as an AVR programmer. I’m hoping this will be more handy and now make me not carry my heavy laptop.

Check it out at:

I’m hoping a LCD and some more controls can actually allow you to code and upload on the fly without even using pre-compiled .HEX files.


Learning Python the Hard Way :)

After getting the RasPi, I was all the more excited to learn Python. I started it from this link

I’m currently in Exercise 22 which asks us to rewind what we’ve learned so far. So I made these notes and will post here for my quick reference.

# Ex 22

Asks to go back and revist all the symbols and words and understand what they all do..

I’m’ gonna begin from ex1

Continue reading “Learning Python the Hard Way :)”