Bash current folder

By | August 8, 2009

Sometimes, if you run some bash scripts from cronjob or with the absolute path you will receive an error like this:

Can’t open perl script “backup.cgi”. No such file or directory.

To solve this, you must make sure you set bash to read from the directory where it is located:

cd $(dirname $0)

This will solve your problem.

apache-2009-7-8-175222.tar.gzSometimes, if you run some bash scripts from cronjob or with the absolute path you will receive an error like this:

apache-2009-7-8-175222.tar.gz

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.