1
PART 1 Ok so i'm using Mac and I started out with a file called...
Example: myFile.sh
In Terminal I ran this file in its directory by typing...
bash myFile.sh
That works perfectly, but then I did some research about bash vs sh and found that I could have also written it like this...
sh myFile.sh
That also worked. I did some more research and an idea came to mind, that since bash is the "newer" way to do things, I thought I would try to rename myFile.sh
to myFile.bash
to see if it would still run in terminal if I typed this...
bash myFile.bash
And it worked perfectly! But now I'm wondering if there is a reason that the file was originally named myFile.sh
instead of myFile.bash
So, is it bad that I renamed it to myFile.bash
instead of myFile.sh
? Or is it totally fine??
(i'm new to Terminal commands)
PART 2
Another question: How would I make this "myFile.sh" executable? This is the contents of myFile.sh below:
#!/bin/bash
python runtime/recompile.py "$@"
NOTE: I did some research and tried renaming myFile.sh to myFile.command which should make it executable when I open the file, but it didn't work and I got this error in Terminal:
python: can't open file 'runtime/recompile.py': [Errno 2] No such file or directory
So my questions really are:
a) How do I make myFile.sh executable in Terminal? b) Why didn't renaming myFile.sh to myFile.command?
Any help appreciated.
1The
can't open file
message means simply thatruntime/recompile.py
doesn't exist. That has nothing to do with the name of yourmyFile.whatever
script. But you probably don't need the shell script at all; just make sure your Python script has#!/usr/bin/python
, runchmod +x
on it, and run it directly. – Keith Thompson – 2011-12-06T09:46:51.860