I am attempting to write my first shell script (I'm running Ubuntu 10.x)
This is what my 'script' looks like
cd /some/path/to/scripts # pwd (if uncommented, this shows we HAVE really changed directory to /some/path/to/scripts # echo `ls` (if uncommented, shows that testscript is in our working directory) # the next line is where bash LIES: 'testscript: No such file or directory' . testscript # (./testscript doesn't work either)
I put the following debug statements (after the cd), in the script above to make sure everything was ok:
pwd echo `ls -lhrt`
and it displayed all the files in the directory. So I dont understand the error message I am getting.
I have changed my question - to focus on the MAIN issue as to why I am getting the 'No such file or directory' error message.
Here are the facts:
- testscript is executable and resides in /some/path/to/scripts
- when I manually type the commands in the script above, testscript runs successfully
My question then is this:
How is it that these same (trivial) commands work on the command line, and yet fail to work when executed from a batch script?.
Equally (if not more important), is the question - how do I fix this?
Put simply I want to write a script that does this:
- Change directory into a specified (hard coded) one
- Run a script in the current working directory