11-15-2005
directories are not getting removed
hello Everyone.
I'm having the following problem:
I have number of installation in the directory. each installation consists of executable file and directory. when I do the new installation I move old one to File_name-Time_stamp. this is done for executable and for directory. Everything is done by shell script and works just fine. Now I want to get rid of old installations and keep only new one and last back up (which is created just before ) this script is working fine except one thing - it does not remove the directory. if I do the same manually - it works just fine, however inside the script it doesn't. Does anyone can help me and explain to me what's wrong in my script?
Thanks a lot in advance!
below is my script:
#!/bin/ksh
#cleanup.ksh
typeset SYS_NAME=$1
typeset TimeStamp="not defined"
typeset toRemove="not defined"
umask 002
function TimeStamp {
TimeStamp=`(set \`/bin/date +%d-%b-%y@%H:%M:%S\`; /bin/echo $1)`
print "TimeStamp: $TimeStamp"
return 0;
}
function cleanup {
for Item in `/bin/ls $SYS_NAME*`
do
toRemove=$Item
print "processing: $toRemove"
if [[ $toRemove != $SYS_NAMEc && $toRemove != $SYS_NAMEc-$TimeStamp && $toRemove != $SYS_NAMEc.1 && $toRemove != $SYS_NAMEc.1-$TimeStamp && $toRemove != "cleanup.ksh" ]]
then
rm -Rf $toRemove
print "$toRemove removed"
else
print "I'm not moving: $toRemove"
fi
done
return 0;
}
function backup {
if [[ -s ${SYS_NAME}c ]]
then
/bin/mv ${SYS_NAME}c ${SYS_NAME}c-${TimeStamp}
print "${SYS_NAME}c-${TimeStamp} has been created"
else
print "Could not create a backup for file ${SYS_NAME}c"
exit
fi
if [[ -d ${SYS_NAME}c.1 ]]
then
/bin/mv ${SYS_NAME}c.1 ${SYS_NAME}c.1-${TimeStamp}
print "${SYS_NAME}c.1-${TimeStamp} directory has been created"
else
print "Could not create a backup for directory ${SYS_NAME}c.1"
exit
fi
return 0;
}
TimeStamp
backup
cleanup
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello all!
I ran rm -rf on a wrong directory, noticed it and hit ctrl-c.
Is there any way on a debian machine to tell what actually got deleted?
As there were many dirs and files in this directory that I don't care for, I'd like to see if anything important was removed.
Or do you know in... (4 Replies)
Discussion started by: thosch
4 Replies
2. Shell Programming and Scripting
Hi ,
I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory.
how to write this in a simple script, I have made my code complex
if ; then
taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies
3. Shell Programming and Scripting
Hello all,
Here's the deal...I have one directory with many subdirs and files.
What I want to find out is who is keeping old files and directories...say files and dirs that they didn't use since a number of n days, only one level under the initial dir. Output to a file.
A script for... (5 Replies)
Discussion started by: ejianu
5 Replies
4. Shell Programming and Scripting
Hi ,
I am very new to unix as well as shell scripting. I have to write a script for the following requirement.
In a particular mount, have to list all the directories and sub directories along with size of the directory and sub directory in ascending order.
Please help me in this regard and many... (4 Replies)
Discussion started by: nmakkena
4 Replies
5. UNIX for Dummies Questions & Answers
Hi,
Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process.
I wanted to disply using a unix command all the directories recursively excluding files.
I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies
6. UNIX for Dummies Questions & Answers
Hi all,
Using grep command, i want to find the pattern of text in all directories and sub-directories.
e.g: if i want to search for a pattern named "parmeter", i used the command
grep -i "param" ../*
is this correct? (1 Reply)
Discussion started by: vinothrajan55
1 Replies
7. Shell Programming and Scripting
Can anyone come up with a unix command that lists
all the files, directories and sub-directories in the current directory
except a folder called log.?
Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies
8. UNIX for Dummies Questions & Answers
It is for HP-Unix B.11.31.
Requirement:
1. List the directories, having given pattern in the directories name, sorted by creation date.
Example: Directories with name "pkg32*" or "pkg33*"
2. On the output of 1. list the directories by creation date as sort order, with creation date... (2 Replies)
Discussion started by: Siva SQL
2 Replies
9. Solaris
I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies
LEARN ABOUT HPUX
uuid-config
UUID-CONFIG(1) Universally Unique Identifier UUID-CONFIG(1)
NAME
uuid-config - OSSP uuid API build utility
VERSION
OSSP uuid 1.6.2 (04-Jul-2008)
SYNOPSIS
uuid-config [--help] [--version] [--all] [--prefix] [--exec-prefix] [--bindir] [--libdir] [--includedir] [--mandir] [--datadir] [--acdir]
[--cflags] [--ldflags] [--libs]
DESCRIPTION
The uuid-config program is a little helper utility for easy configuring and building applications based on the uuid(3) library. It can be
used to query the C compiler and linker flags which are required to correctly compile and link the application against the uuid(3) library.
OPTIONS
uuid-config accepts the following options:
--help
Prints the short usage information.
--version
Prints the version number and date of the installed uuid(3) library.
--all
Forces the output of all flags, that is, including extra flags which are not OSSP uuid specific.
--prefix
Prints the installation prefix of architecture independent files
--exec-prefix
Prints the installation prefix of architecture dependent files.
--bindir
Prints the installation directory of binaries.
--libdir
Prints the installation directory of libraries.
--includedir
Prints the installation directory of include headers.
--mandir
Prints the installation directory of manual pages.
--datadir
Prints the installation directory of shared data.
--acdir
Prints the installation directory of autoconf data.
--cflags
Prints the C compiler flags which are needed to compile the uuid(3)-based application. The output is usually added to the CFLAGS
uuidiable of the applications Makefile.
--ldflags
Prints the linker flags (-L) which are needed to link the application with the uuid(3) library. The output is usually added to the
LDFLAGS uuidiable of the applications Makefile.
--libs
Prints the library flags (-l) which are needed to link the application with the C uuid(3) library. The output is usually added to the
LIBS uuidiable of the applications Makefile.
EXAMPLE
CC = cc
CFLAGS = -O `uuid-config --cflags`
LDFLAGS = `uuid-config --ldflags`
LIBS = -lm `uuid-config --libs`
all: foo
foo: foo.o
$(CC) $(LDFLAGS) -o foo foo.o $(LIBS)
foo.o: foo.c
$(CC) $(CFLAGS) -c foo.c
SEE ALSO
uuid(3), uuid(1), OSSP::uuid(3).
04-Jul-2008 OSSP uuid 1.6.2 UUID-CONFIG(1)