Register
It is currently Tue Sep 02, 2014 10:42 pm

Helping Bash Newbie Improve a Zip Script!


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Sun Jul 09, 2006 10:37 am   

Joined: Sun Jul 09, 2006 8:21 am
Posts: 1
I'm very new to Bash scripting (about 2 days), but not completely new to programming. I've devised a zip script through research here and other sites, and am looking for ways to improve it. Here are ways I think it could be improved, but am not sure where to start, or in some cases (#8 and #9) do not know how to do at all.

1. ensure script ran successfully (i.e. all files were unzipped)
2. output errors to a log
3. if error log is created OR has new entries added to it, mail to administrator
4. ensure script ran successfully (i.e. all files were unzipped)
5. look for files not just ending in zip, but also beginning with 'IF' (case insensitive)
6. If $size 0, mail warning that no image files were available for unzipping to administrator
7. make paths more dynamic for easy porting to different webservers (i.e. localhost vs. remote)
8. how to call this script from a PHP file; ie. if bashscript == true, go on to next item.
9. making this more dynamic, based on parameters I set in a PHP script

unzip.sh

Code:
#!/bin/bash

DIR='../../../test'
cd $DIR
FILENAME=($(find . -name "*.zip" -type f|tr -d "%.zip" |tr -d "##*/"))
SIZE=${#FILENAME[@]}

if [ $SIZE > 0 ]; # needs to be at least 1 .zip file in directory
then
        for ((index=0; index<SIZE; index++))
        do {
                T=${FILENAME[$index]}
                #echo $T
                mkdir /../rw-pw/images/listings/$T
                unzip -P password $T.zip -d '../rw-pw/images/listings/'$T
           }
        done
fi


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP