First, it works on my work computer, but doesn't work on my home desktop. Second, I've explored several previous answers, with no luck. Perhaps I just didn't read the ONE that has my solution.
I want to run an executable python script from anywhere (it takes one string argument). My solution is to use a bash alias in .bashrc:
I have tried several variants:
alias tlog="~/projects/tlog/tlog.py"
alias tlog="/c/cyg/home/<my_username>/projects/tlog/tlog.py"
alias tlog="C:\\cyg\\home\\<my_username>\\projects\\tlog\\tlog.py"
alias tlog='"/c/cyg/home/<my_username>/projects/tlog/tlog.py"'
alias tlog='"C:\\cyg\\home\\<my_username>\\projects\\tlog\\tlog.py"'
alias tlog="python ~/projects/tlog/tlog.py"
None of them work, the respective outputs are:
C:\Python27\python.exe: can't open file '/home/<my_username>/projects/tlog/tlog.py': [Errno 2] No such file or directory
C:\Python27\python.exe: can't open file '/c/cyg/home/<my_username>/projects/tlog/tlog.py': [Errno 2] No such file or directory
bash: C:cyghome<my_username>projectstlogtlog.py: command not found
C:\Python27\python.exe: can't open file '/c/cyg/home/<my_username>/projects/tlog/tlog.py': [Errno 2] No such file or directory
bash: C:\cyg\home\<my_username>\projects\tlog\tlog.py: command not found
C:\Python27\python.exe: can't open file '/home/<my_username>/projects/tlog/tlog.py': [Errno 2] No such file or directory
So for a sanity check, I did this:
$ cd ~/projects/tlog
$ ls
logs prev_log_date tlog.py
Yep it's there... so does it run?
$ ./tlog.py "TEST"
yadda yadda it worked
Yep, so now:
$ ~/projects/tlog/tlog.py "TEST"
C:\Python27\python.exe: can't open file '/home/<my_username>/projects/tlog/tlog.py': [Errno 2] No such file or directory
Well... what about
$ more ~/projects/tlog/tlog.py
#!/usr/bin/env python
"""
tlog - tlog docstring
"""
...rest of file...
Yep, it's still there. Anyone got an answer for me? For reference:
$ ls -la
...more files...
-rwxrwxr-x+ 1 <my_username> <my_username> 6376 Nov 10 17:59 tlog.py
$ cd ..
$ ls -la
...more files...
drwxr-xr-x+ 1 <my_username> <my_username> 0 Nov 10 17:59 tlog
$ python --version
Python 2.7.10
PATH=$PATH:$HOME/projects/tlog