Hi all!
I'm really hoping you can help me out here; now i have searched and searched and have at least worked out that you can't have a nested if statement with a 'done' in it (as i have) as you're killing the parent before the child.
So here's what i have, and here's hoping someone can help me think of a work around! FYI, i'm using bash on a custom linux build, fairly standard based around red hat i believe(?)
The script is to find all attached USB devices, and copy a folders contents to it. The issue is within the variable check at the start, and the two unmounting after replication parts.
Theres a few other parts later on which i haven't posted which have a similar issue- so any ideas would be great!
Code:
# Assigning Drive variables and locating available disks.
alldrives=$(df -h | grep sda | awk '{print$1}' | cut -c1-8)
d1=$(echo $alldrives | awk '{print$1}')
d2=$(echo $alldrives | awk '{print$2}')
d3=$(echo $alldrives | awk '{print$3}')
d4=$(echo $alldrives | awk '{print$4}')
d5=$(echo $alldrives | awk '{print$5}')
d6=$(echo $alldrives | awk '{print$6}')
d7=$(echo $alldrives | awk '{print$7}')
d8=$(echo $alldrives | awk '{print$8}')
d9=$(echo $alldrives | awk '{print$9}')
d10=$(echo $alldrives | awk '{print$10}')
for i in $d1 $d2 $d3 $d4 $d5 $d6 $d7 $d8 $d9 $d10
do
if [[ -z $i ]]
then
echo "Variable blank, moving to next"
done
fi
#CHECK FOR MOUNTABLE DRIVE, MAKE DIR FOR IT
mkdir /mnt/clone/
if mount "$i""1" /mnt/clone/"$i""1"
then
# START REPLICATION
echo "BEGINNING RSYNC REPLICATION"
rsync -rtv --progress --modify-window=1 --exclude=LOCAL.CFG /usr/local/FOLDER1 /mnt/clone/"$i""1"/usr/local/FOLDER1
echo
# UNMOUNT AFTER REPLICATION
if umount /mnt/clone/"$i""1"
then
echo "Unmounted Successfully. Copying Complete."
done
else
# FORCE IF UNABLE TO UNMOUNT
echo "Forcing unmount..."
sync
sleep 15
cd /
umount -f /mnt/clone/"$i""1"
done
fi
fi
Hi -
Trying to take a list of ldap suffixes in a file, run an ldapsearch command on them, then run a grep command to see if it's a match, if not, then flag that and send an email alert.
The list file (ldaplist) would look like -
***********
o=company a
o=company b
***********
**... (7 Replies)
In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands.
How do I write the "do nothing" statement in the following example?
Example:
if (( "$x"="1" && "$y"="a" && "$z"="happy" ))
then
do nothing
else
command
command
fi... (3 Replies)
Hi All,
I am using Unix ksh script.
I need to insert values to a table using the o/p from a slelect statement.
Can anybody Help!
My script looks like tihs.
---`sqlplus -s username/password@SID << EOF
set heading off
set feedback off
set pages 0
insert into ${TB_NAME}_D... (2 Replies)
I'm trying to write case statements with 'if statements' embedded inside of them. I'm using the korn shell but it's not functioning.
If I want to see if a string exists in a file and then perform an action, what would be the best way to do this?
For file "asg51fin" to delete a line if a... (1 Reply)
I'm just having a bit of trouble running this code. It tells me that there's a syntax error on line 29. Any help appreciated.
#!/usr/bin/perl
#
# Phone Book Application
#
%phonebook = (
"Wayne", '34687368',
"Home", '378643287',
"Work", '017374637',
"School",... (2 Replies)
Hi,
i m trying to create script which logic is like below.
if ; then
x=`cat /tmp/testoutput.log | grep STOP | wc -l`
y=`cat /tmp/testoutput.log | grep RUN | wc -l`
if ; then
echo "process stop"
if ; then
echo "process running "
else
echo "file not found"
fi
----------------... (2 Replies)
I am having a problem with a nested if. I am sure I am overlooking something. I check for the existence of $Pidfl3 and it exists, o this condition I then want to check for the existence of a next file and remove it. The first if is executed, but on the second if I get test: argument expected.
My... (4 Replies)
Hi folks,
I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex.
I have a bunch of update statements with all columns in a file which I need to convert into insert statements.
UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies
LEARN ABOUT OSX
echo
ECHO(1) BSD General Commands Manual ECHO(1)NAME
echo -- write arguments to the standard output
SYNOPSIS
echo [-n] [string ...]
DESCRIPTION
The echo utility writes any specified operands, separated by single blank (' ') characters and followed by a newline ('
') character, to the
standard output.
The following option is available:
-n Do not print the trailing newline character. This may also be achieved by appending 'c' to the end of the string, as is done by iBCS2
compatible systems. Note that this option as well as the effect of 'c' are implementation-defined in IEEE Std 1003.1-2001
(``POSIX.1'') as amended by Cor. 1-2002. Applications aiming for maximum portability are strongly encouraged to use printf(1) to sup-
press the newline character.
Some shells may provide a builtin echo command which is similar or identical to this utility. Most notably, the builtin echo in sh(1) does
not accept the -n option. Consult the builtin(1) manual page.
EXIT STATUS
The echo utility exits 0 on success, and >0 if an error occurs.
SEE ALSO builtin(1), csh(1), printf(1), sh(1)STANDARDS
The echo utility conforms to IEEE Std 1003.1-2001 (``POSIX.1'') as amended by Cor. 1-2002.
BSD April 12, 2003 BSD