Options
Please review my bash script
Can you guys take a quick look at my bash script?
If I run sh copy.sh it tells me (23: Syntax error: Bad for loop variable)
and if I run ./copy.sh it tells me (./man_fs2-copy.sh: line 28: syntax error near unexpected token `done'
./man_fs2-copy.sh: line 31: `done cat /tmp/error.log | mail -s "Here is the log for $share" $email && rm /tmp/error.log')
What am I doing wrong?
If I run sh copy.sh it tells me (23: Syntax error: Bad for loop variable)
and if I run ./copy.sh it tells me (./man_fs2-copy.sh: line 28: syntax error near unexpected token `done'
./man_fs2-copy.sh: line 31: `done cat /tmp/error.log | mail -s "Here is the log for $share" $email && rm /tmp/error.log')
What am I doing wrong?
#!/bin/bash # # # This script will create the necessary directories, mount man_fs2 (c$, e$, f$ and g$) # then read from directorylist.txt and start copying the directory's # # echo "What is your email address?" read email # # mkdir -p /servers/backups /servers/man_fs2 /servers/man_fs2-logs mkdir -p /home/man_fs2/c /home/man_fs2/e /home/man_fs2/f /home/man_fs2/g chmod -R 777 /servers cd /servers # # Mount man_fs2 mount //man_fs2/c$ /home/man_fs2/c -oacl,username=administrator@domain.local,password=..... mount //man_fs2/e$ /home/man_fs2/e -oacl,username=administrator@domain.local,password=..... mount //man_fs2/f$ /home/man_fs2/f -oacl,username=administrator@domain.local,password=..... mount //man_fs2/g$ /home/man_fs2/g -oacl,username=administrator@domain.local,password=..... # # for (( c=1; c<=2; c++ )) do cat directorylist.txt | while read source dest share cp -Rv "$source" "$dest" 2> /tmp/error.log echo "Setting ACLs from $source to $dest:" getfacl -R "$source" | setfacl -R --set-file=- "$dest" done cat /tmp/error.log | mail -s "Here is the log for $share" $email && rm /tmp/error.log echo "Pass # $c" if [ ! -d "$src" ]; then cp -aR $src $dest getfacl -R $src | setfacl -R --set-file=- $dest else cp -uR $src $dest getfacl -R $src | setfacl -R --set-file=- $dest fi done echo "Unmount all drives" umount /home/man_fs2/c umount /home/man_fs2/e umount /home/man_fs2/f umount /home/man_fs2/g exit
Comments
-
Optionsqwertyiop Member Posts: 725 ■■■□□□□□□□I fixed the issue that I was having but im now having trouble with another part of my script, specifically when I try to do the getfacl/setfacl.
Setting ACLs from "/home/man_fs2/e/couplings*" to "/servers/man_fs2/couplings":
getfacl: "/home/man_fs2/e/couplings*": No such file or directory
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...