0

I request for help and would appreciate it if someone could help me with my shellscript struggle. The following code is my shellscript to resign the zone-file.

#!/bin/bash
hash=$(head -c 1000 /dev/random | sha1sum | cut -b 1-16)
command=$(dnssec-signzone -3 $hash –N 'KEEP' –o "owolf.dnssec.local" –t /etc/bind/zones/db.owolf.dnssec.local)
sleep 10
service bind9 reload

When i start the script manually it gives me two errors and i can't figure out why.

First Error: !/bin/bash: No such file or directory

I checked it bash is present in the directory /bin.

Second Error: -N Could not open file.

Seems to be an error with the quoting but i already tried ",' and ´ none of them worked.

What else have i tried? I also tried and made sure, that the line endings are converted in unix style, and that there are no other missplaced symbols in the file.

SOLVED The file seems to be broken, created a new file and manually filled in the code. Also fixed some wrong quotes.

#!/bin/bash
hash=$(head -c 1000 /dev/random | sha1sum | cut -b 1-16)
dnssec-signzone -3 "$hash" –N "KEEP" –o "owolf.dnssec.local" –t /etc/bind/zones/db.owolf.dnssec.local
sleep 10
service bind9 reload
lt_katana
  • 148
  • 3
  • 12
  • but you are using `bash` in your terminal window? Confirm this echo `echo $BASH_VERSION`. Now use `type bash` or `which bash` to see the full path name. Maybe it is stored in `/usr/bin/` or similar? I don't understand why you're storing output into `command=$(...)` , you're not using `$command` in your script. Good luck. – shellter Dec 08 '15 at 21:35
  • 1
    Try changing first line to `#!/bin/bash -xv`. Try surrounding `$hash` with double quotes. What is `command` for? – Mark Setchell Dec 08 '15 at 21:35
  • which bash gives me /bin/bash. command was a try to fix the error that occured when i only executed the dnssec-signzone command. Bash_Version is: 4.3.30(1)-release. With double quotes around $hash and -xv behind /bin/bash -> same exact problem – lt_katana Dec 08 '15 at 22:19
  • What happens if you start lines 2-5 with a hash sign (`#`) and add a new line that says `echo hello`. Does it run then? – Mark Setchell Dec 08 '15 at 22:23
  • Following output: ./resign.sh: line 1: #!/bin/bash: No such file or directory hello. whereis bash gives me the path /bin/bash – lt_katana Dec 08 '15 at 22:24

1 Answers1

0

The file seems to be broken, created a new file and manually filled in the code. Also fixed some wrong quotes.

#!/bin/bash
cd /var/cache/bind/ #Key Material is there
hash=$(head -c 1000 /dev/random | sha1sum | cut -b 1-16)
dnssec-signzone -3 "$hash" –N "KEEP" –o "owolf.dnssec.local" –t /etc/bind/zones/db.owolf.dnssec.local
sleep 10
service bind9 reload

– lt_katana

lt_katana
  • 148
  • 3
  • 12
Armali
  • 18,255
  • 14
  • 57
  • 171