Larry Wall: “Shell programming is a 1950s juke box …”
In this short blog I write a small Python utility script to create directories and demonstrate how to utilize it and pass it arguments via BASH shell script. The functionality is similar to the ‘mkdir’ UNIX command. The name of the directory or directories to be created is the argument I pass in to the Python script. I then create a BASH shell script to call the Python script.
The BASH shell script file takes in a argument(s) and passes the argument(s) to the Python script file. I make the BASH script file an executable with the “chmod +x [BASH script name]” command; I can then put this small utility script in one my path directories as shown by the “echo $PATH” command and call it anytime as needed from the shell.
Python script code (mkd.py):
BASH shell script code (mkd):
Tags: BASH, BASH pass argument, BASH pass argument to command, BASH pass argument to python script, BASH pass argument to script, BASH Shell, Bash Shell Scripting, linux, MAC, Mac OS X, Mac OS X Mavericks, Mavericks, mkdir, OS X Mavericks, Python, Python 3, Python pass argument, Python pass arguments, python3, scripting, shell, shell script, shell scripting, Unix