Bash script - im missing something and cant's figure out what
I just put together a script for work that will essentially automate the migration of our Windows fileserver to my newly created Debian based SAMBA server.
My script will create the necessary directories then copy the data over to my new server, after that it will set the ACL's by using getfacl/setfacl.
I tried to run my script by using ./man_fs2-copy.sh:
Code:
./man_fs2-copy.sh: line 28: syntax error near unexpected token `done'
./man_fs2-copy.sh: line 28: `done cat /tmp/error.log | mail -s "Here is the log for $share" $email && rm /tmp/error.log'
I also tried to run the script like this, sh man_fs2-copy.sh and I get the following error,
Code:
man_fs2-copy.sh: 22: Syntax error: Bad for loop variable
Code:
#!/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
I change my default shell to zsh but can't find the init files, .zshrc and .zlogin from /export/home and /home. The other shells init files are there:.cshrc, .profile and .login. Am I suppose to use these as templates?
Also, bash_history is there but not zsh_history although zsh do keep a... (2 Replies)
First off thank you for any help.
Here is the problem. I have two text files that fit the same format. The first I created using an ls -d command and then with the help of the forums ran awk resulting in the fallowing output.
W00CHZ0103345-I1CZ44
W00E6S1016722-I01JW159... (8 Replies)
Ok, i've been messing around in debian the past few days, setting up programs like subversion, mysql and logrotate. The purpose of this script is to use subversion to backup the binary logs. It runs in the cron every 2 hours or so (although I can't get my script to run properly atm, which is why... (1 Reply)
Before I begin with the question, I just want to point out that I just started learning unix in the middle of last week, so my code (and knowledge of how unix operates) is weak sauce. I took my best stab at this question but it's just not working.
Assignment:
Create a script named... (1 Reply)
If I have a file called file A with a list of filenames. How do I find all the filenames in file A that aren't contained in file B?
I want to use bash scripting. (2 Replies)
Gey guys,
I'm a new learner of perl. Now I encountered a problem when I tried to get the output below from the input file.
Input:
5'h1f, 16'h8210
write, 5'h10, 16'h0000
write, 5'h11, 16'h0000
5'h1f, 16'hffd0
write, 5'h1e, 16'h0000
5'h1f, 16'h8310
read, 5'h10, rd_data
5'h1f,... (3 Replies)
hii please help me this is the script
num=$1
sum=0
while
do
x=`expr $num % 10`
sum=`expr $sum + $x`
num=`expr $num / 10`
done
echo "Summation is $sum"
it is giving error
pratyush@ubuntu:~$ sh shell.sh 123
shell.sh: 11: 123: not found
Summation is 0 (3 Replies)
Hi!
(I guess this could of gone into the scripting forum, but Unix for Dummies seemed more appropriate. Please note that I am not in school, so Homework doesn't seem appropriate either. You guys can let me know if you think otherwise.)
I am following an exercise in a book on ksh scripting which... (2 Replies)
Hi Again,
I have a file that contains date and time for the past 2 hours. What i need is add missing date and time in a file.
INPUT
2016-01-13 01:33 10
2016-01-13 01:31 10
2016-01-13 01:30 10
2016-01-13 01:29 10
2016-01-13 01:28 10
2016-01-13 01:27 10
2016-01-13 01:26 10
2016-01-13... (14 Replies)
Discussion started by: ernesto
14 Replies
LEARN ABOUT SUSE
sieveshell
SIEVESHELL(1) User Contributed Perl Documentation SIEVESHELL(1)NAME
sieveshell - remotely manipulate sieve scripts
SYNOPSIS
sieveshell [--user=user] [--authname=authname] [--realm=realm] [--exec=script] server[:port]
sieveshell --help
DESCRIPTION
sieveshell allows users to manipulate their scripts on a remote server. It works via MANAGESIEVE, a work in progress.
The following commands are recognized:
list list scripts on server.
put <filename> upload script to server.
get <name> [<filename>] get script. if no filename display to stdout
delete <name> delete script.
activate <name> activate script.
deactivate deactivate all scripts.
OPTIONS -u user, --user=user
The authorization name to request; by default, derived from the authentication credentials.
-a authname, --authname=authname
The user to use for authentication (defaults to current user).
-r realm, --realm=realm
The realm to attempt authentication in.
-e script, --exec=script
Instead of working interactively, run commands from script, and exit when done.
REFERENCES
[MANAGESIEVE] Martin, T.; "A Protocol for Remotely Managing Sieve Scripts", draft-ietf-managesieve-03.txt, Mirapoint, Inc.; May 2001, work
in progress.
AUTHOR
Tim Martin <tmartin@mirapoint.com>, and the rest of the Cyrus team <cyrus-bugs@andrew.cmu.edu>.
perl v5.10.0 2008-04-04 SIEVESHELL(1)