Sponsored Content
Top Forums Shell Programming and Scripting Bash script - im missing something and cant's figure out what Post 302522535 by binary-ninja on Sunday 15th of May 2011 07:57:36 PM
Old 05-15-2011
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

 

10 More Discussions You Might Find Interesting

1. Solaris

Missing init files for zsh and bash

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)
Discussion started by: maag
2 Replies

2. Shell Programming and Scripting

Bash uniq/ diff/ and other I cant figure it out

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)
Discussion started by: Movomito
8 Replies

3. Shell Programming and Scripting

Bash script error: missing destination file name operand.

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)
Discussion started by: cganly
1 Replies

4. Shell Programming and Scripting

Spent all day trying to figure this script out...

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)
Discussion started by: ashkali1
1 Replies

5. Shell Programming and Scripting

Find missing string with bash

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)
Discussion started by: locoroco
2 Replies

6. Shell Programming and Scripting

Anybody here can help me to figure thie perl script out?

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)
Discussion started by: sunbaby
3 Replies

7. Shell Programming and Scripting

cant figure out the error in this script (adding numbers in a string) using ubantu shell

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)
Discussion started by: Pratyush Sakhle
3 Replies

8. UNIX for Dummies Questions & Answers

[Solved] ksh script - can't figure out what's wrong

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)
Discussion started by: sudon't
2 Replies

9. Shell Programming and Scripting

Help with change significant figure to normal figure command

Hi, Below is my input file: Long list of significant figure 1.757E-4 7.51E-3 5.634E-5 . . . Desired output file: 0.0001757 0.00751 0.00005634 . . . (10 Replies)
Discussion started by: perl_beginner
10 Replies

10. Shell Programming and Scripting

How to add missing date and time in a bash script?

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
cachefslog(1M)						  System Administration Commands					    cachefslog(1M)

NAME
cachefslog - Cache File System logging SYNOPSIS
cachefslog [-f logfile | -h] cachefs_mount_point DESCRIPTION
The cachefslog command displays where CacheFS statistics are being logged. Optionally, it sets where CacheFS statistics are being logged, or it halts logging for a cache specified by cachefs_mount_point. The cachefs_mount_point argument is a mount point of a cache file system. All file systems cached under the same cache as cachefs_mount_point will be logged. OPTIONS
The following options are supported. You must be super-user to use the -f and -h options. -f logfile Specify the log file to be used. -h Halt logging. OPERANDS
cachefs_mount_point A mount point of a cache file system. USAGE
See largefile(5) for the description of the behavior of cachefslog when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes). EXAMPLES
Example 1: Checking the Logging of a directory. The example below checks if the directory /home/sam is being logged: example% cachefslog /home/sam not logged: /home/sam Example 2: Changing the logfile. The example below changes the logfile of /home/sam to /var/tmp/samlog: example# cachefslog -f /var/tmp/samlog /home/sam /var/tmp/samlog: /home/sam Example 3: Verifying the change of a logfile. The example below verifies the change of the previous example: example% cachefslog /home/sam /var/tmp/samlog: /home/sam Example 4: Halting the logging of a directory. The example below halts logging for the /home/sam directory: example# cachefslog -h /home/sam not logged: /home/sam EXIT STATUS
The following exit values are returned: 0 success non-zero an error has occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
cachefsstat(1M), cachefswssize(1M), cfsadmin(1M), attributes(5), largefile(5) DIAGNOSTICS
Invalid path It is illegal to specify a path within a cache file system. SunOS 5.10 7 Feb 1997 cachefslog(1M)
All times are GMT -4. The time now is 02:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy