Command Line Parameters for Your Batch Script

When using python as a driver program to lot of other apps, usage of batch files in windows system is something everyone encounters

And when it comes to batch files, sending command line arguments to batch file is one thing i tend to google a lot. A command line argument (or parameter) is any value passed into a batch script. So for convenience, I am listing the most common usages that I needed last year

%* for all command line parameters (excluding the script name itself).

%0 - the command used to call the batch file (could be foo, ..\foo, c:\bats\foo.bat, etc.)
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till %9 (and SHIFT can be used for those after the 9th).

%~nx0 - the actual name of the batch file, regardless of calling method (some-batch.bat)
%~dp0 - drive and path to the script (d:\scripts)
%~dpnx0 - is the fully qualified path name of the script (d:\scripts\some-batch.bat)

More info examples at

Computer Name in Python 3 ways


Get the computer name in python without using any external module or library


import platform
import socket
import os

# first 
# second
# third

Shutil to Rescue

As part of my work, need to run simulations which are driven by python’s sub process module is the work horse for this. But there’s a problem.

On Windows,the subprocess module doesn’t look in the PATH unless you pass shell=True. However, shell=True can be a security risk if you’re passing arguments that may come from outside your program.

To make subprocess nonetheless able to find the correct executable, we can use shutil.which.

Suppose the executable in your PATH is named data_loader:[shutil.which('data_loader'), arg1, arg2])
shutil.which(cmd, mode=1, path=None)

Given a command, mode, and a PATH string, return the path which
conforms to the given mode on the PATH, or None if there is no such

Increasingly I am loving the shutil library it’s so versatile..


This is the word cloud of the books I have read in 2019.

Here’s the list of the books.

  • Atomic habits by James Clear
  • My India by Jim Corbett 
  • Scale by Geoffrey West (A)
  • The happiness equation by Neil Parsricha
  • Think like Sherlock by Peter Hollins
  • Science of likability by Patrick king
  • Antifragile by Nassim Nicholas Taleb
  • Alchemy of air by Thomas Hager
  • E=mc2 by David Bodanis
  • The secrets of happy families by Bruce Fieler
  • Wine by Rod Philips
  • The ghost map by Stephen Johnson
  • No one at the wheels by Sam Schwartz
  • Digital minimalism by Cal Newport
  • Farsighted by Stephen Johnson
  • Skin in the game by Nassim Nicolas Taleb
  • Gold by Mathew Hart
  • India conquered by Jon Wilson
  • When by Daniel H Pink
  • What Adam Smith can teach you Russ Robert
  • Science of food by Marty Jobson
  • The flight attendant by Chris Bohjalian (F)
  • Power of moments by Dan and Chip Heath
  • Spy school by Stuart Gibbs (F)
  • The memory code by L Kelly 
  • Fibre by Susan Crowford
  • An appetite for wonder by Richard Dawkins
  • How to have a good day by Caroline Web
  • The perfect bet by Adam Kucharski
  • The inmitibale Jeeves by P G Wood house (F)
  • The neuroscience of mindfulness by Stan Rodski
  • Humble pie by Matt Parker
  • The doomsday machine by Michale Lewis
  • Humans a brief history of how we f*cked it all up -Tom Philips
  • The Success Equation: Untangling Skill and Luck in Business, Sports, and Investing by Michael J. Mauboussin
  • The ape that understood the universe by Steve Stuart Williams (A)
  • The Little Book of String Theory by Steven Scott Gubser
  • Creating the Twentieth Century: Technical Innovations of 1867-1914 and Their Lasting Impact by Vaclav Smil
  • The passengers by John Marrs(F)
  • Range: Why Generalists Triumph in a Specialized World by David Epstein
  • Our mathematical universe by Max tegmark
  • The big shot by Michale Louise
  • The one by John Marrs (F)
  • I contain multitudes by Ed Yong
  • The Subtle Art of Not Giving a F*ck by Mark Manson
  • Logic of life by Tim Hartford
  • It all adds up by Mickale Launy
  • Birth of a Theorem: A Mathematical Adventure by Cédric Villani
  • Digital minimalism by Cal Newport
  • Cubed secret history of the office by Nikil Saval
  • Cities the first 6000 years by Monica L Smith 
  • Ultralearning by Scott young
  • Everyday biases by Ross Howard J
  • Rebel ideas by Matthew Syed(R)
  • Why we sleep by Matthew Walker
  • Pleased to meet me by Bill Sullivan 
  • The greatest show on earth by Richard Dawkins
  • Math on the back of the envelope by Rob Eastaway
  • Idiot brain by Dean Burnnet
  • Pig wrestling by Pete Lindsay
  • Replay by Kin Grimwood (F) 
  • Elon musk by B Storm
  • Meet your happy chemicals by Loretta Buenning
  • Genesis by Robin Cook (F)
  • Indistractable: How to Control Your Attention and Choose Your Life by Nir Eyal

My top favorites

  • Why we sleep by Matthew Walker
  • Replay by Kin Grimwood
  • Rebel ideas by Matthew Syed
  • The ape that understood the universe by Steve Stuart Williams
  • India conquered by Jon Wilson
  • The ghost map by Stephen Johnson
  • Skin in the game by Nassim Nicolas Taleb
  • The Subtle Art of Not Giving a F*ck by Mark Manson

Sound Alarm When Program Execution Completes in Python

Often one faces a situation where your code takes extremely long to run and you don’t want to be staring at it all the time but want to know when it is done.

In engineering analysis, simulation take a long time to run and the python driver program take a long time to finish and I face this problem a lot.

A simple solution is adding a beep at the end, here’s how to do it in python.

def beep():
    print "\a"


works on windows/ linux/mac without any modification.

via here

Kids painting

This year started with no internet at our house.

On the evening of 27th December, a day after Boxing Day, the Internet of the home suddenly went down and it remained down till 2nd January.

This is the first time after so many years that the family as a whole has experienced such forced internet break.

For the first time 10 hours, as a family we had looked at the internet router more than in the last 5 years combined.

For the first time everyone had more time than we ever realized. So we started painting, rediscovered board games and kids completed thrice the number of books that they did with internet on.

Painting by kids.

Hope to curve out few days like this again?