My script won't run, mum.
Introduction:
For some reason, your shell script craps out. Let's debug it...
Aim:
To identify and fix problems with shell script execution.
1. bad interpreter
Symptom:
when you run the script, you get the error message; 'bad interpreter: No such file or directory'
Investigation:
Run this:
$ head -1 'script name' | od -c
If your output looks something like this:
- 000000 # ! / b i n / b a s h \r \n
- ^
- |
- then your problem is right here -+
What it should look like is this:
- 000000 # ! / b i n / b a s h \n
This is also an example of the use of the 'magic number' in a script. Where the first line reads '#!/bin/bash', this tell Linux to run the script in the bash shell. Likewise, '#!/bin/sh' tell it to use the Bourne shell.
Where Windoze adds the carriage return, Linix tries to use the /bin/bash[carriage return] shell and no such thing exists.
Fix:
Fortunately, the fix is easy:
0 Comments:
Post a Comment
<< Home