This is for a small project proposal.
I want to create many user defined unix commands and perform various operations on files using codes written in Python.
E.g. extractinfo 'filename' [This command would extract the metadata or general information stored in some file]
This is how I am going around:
1. Suppose I have a python code extract.py.
2. Now, in order to create 'my own unix command' (say - 'extractinfo') , I write a shell script named - extractinfo:
#/bin/bash
python /home/extract.py
3. Now, I want to place the above shell script in /usr/bin. So I create another shell script - install.sh:
#!/bin/bash
chmod u+x extractinfo
sudo cp extractinfo /usr/bin/
4. Now I can just run install.sh and use the command 'extractinfo'.
The problem is, if I use another system and run install.sh, the command 'extractinfo' becomes available but then on executing the command on terminal, an error (python: can't open file 'extract.py': [Errno 2] No such file or directory) is thrown.
How to take care of the path of the original python script when one needs to use another system?
I know trying to link shell and python is very crude way of doing things. Any help/suggestions, in regards to this problem, are appreciated.