0

rebuild the udev rules in the /etc/udev/rules.d/99-oracle-asmdevices.rules file by running the following script:

 i=1
          cmd="/sbin/scsi_id -g -u -d"
          for disk in sdb sdc sdd sde sdf; do 
                   cat <<EOF >> /etc/udev/rules.d/99-oracle-asmdevices.rules
          KERNEL=="sd?1",SUBSYSTEM=="block", PROGRAM=="$cmd /dev/\$parent", \
           RESULT=="`$cmd /dev/$disk`", SYMLINK+="asm-disk$i", OWNER="grid", GROUP="dba", MODE="0660"
          EOF
                   i=$(($i+1))

Error_Message:

script.sh: line 11: syntax error: unexpected end of file [root@london1 sf_D_DRIVE]# warning: here-document at line 5 delimited by end-of-file (wanted EOF') -bash: syntax error near unexpected token ('

  • While an interesting code challenge, at the end of the day if you would have simply opened the file with vi and manually adjusted/inserted the settings, you would be be done by now. There aren't but 5 lines in the file to be dealt with – EdStevens Nov 27 '20 at 15:19
  • Sometimes it's worth knowingly overcomplicating a task to learn how to handle more complex problems. It *is* good to know when to just handle it manually too, though. – Paul Hodges Dec 01 '20 at 14:18

1 Answers1

0

First, https://www.shellcheck.net/ - bookmark it, use it.

My corrections and tweaks -

#!/bin/bash
i=0
cmd="/sbin/scsi_id -g -u -d"
for disk in sdb sdc sdd sde sdf
do ((i++)); cat >> /etc/udev/rules.d/99-oracle-asmdevices.rules <<EOF
      KERNEL=="sd?1",SUBSYSTEM=="block", PROGRAM=="$cmd /dev/\$parent", \
       RESULT=="$($cmd /dev/$disk)", SYMLINK+="asm-disk$i", OWNER="grid", GROUP="dba", MODE="0660"
EOF
done
Paul Hodges
  • 13,382
  • 1
  • 17
  • 36