Deex
Deex

Reputation: 327

Bin Bash file not found

i'm really beginner with SH Scripts.

I found a small sh script that convert a php file with wget to html. I would like to do a small cronjob with it. But everytime i run that script i get the message (Translated) "Defect Interpreter" > File or folder not Found".

My script is only

#!/bin/bash
rm -rf header-wrapper.html && wget http://master.gnetwork.eu/header-wrapper.php -O header-wrapper.html -q

Upvotes: 1

Views: 5258

Answers (3)

You can get this too, if you use Windows line ending CR/LF instead of Linux line ending LF.

Upvotes: 0

The Derpiest Coder
The Derpiest Coder

Reputation: 111

Try typing Bash in before the filename.

bash [File Name Here]

instead of

.[File Name Here]

Sorry if someone else already answered this.

Upvotes: 0

Eugeniu Rosca
Eugeniu Rosca

Reputation: 5315

The error message tells you that your shebang is wrong (bash executable is not found at /bin/bash when cron job starts).

From your cron job, use bash explicitly when calling the script:

bash myscript.sh

instead of:

./myscript.sh

Also, do not make any assumptions on the working directory of the cron job. Change the directory in your bash script before doing anything else

#!/bin/bash
cd /my/desired/path && \
rm -rf header-wrapper.html && \
wget http://master.gnetwork.eu/header-wrapper.php -O header-wrapper.html -q

Upvotes: 2

Related Questions