The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Convert shell script for looping le0pard13 Shell Programming and Scripting 4 06-07-2007 08:42 PM
Looping script with variables jojojmac5 Shell Programming and Scripting 1 07-11-2006 12:43 AM
looping a array inside inside ssh is not working, pls help reldb Shell Programming and Scripting 5 07-07-2006 11:32 AM
Perl question - looping through an array of hashrefs kregh99 Shell Programming and Scripting 2 03-19-2004 10:48 AM
Looping a perl script in a shell script edkung Shell Programming and Scripting 8 10-04-2002 11:28 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-18-2008
kelldan kelldan is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 12
KSH script not looping through array

Hi All,

I'm trying to get a script to loop through an array. The array is basically a list of .zip files. I'd like the script to loop through and unzip the zip files contained in the zip file list. When I run the script, it unzip the first zip file correctly, and then stops Any thoughts? Here's the script:


Code:
#!/usr/bin/ksh 
clear
# setting up the date to be something a bit more pretty
DATE=`date +%m/%d/%y-%H:%M`
# This date variable is used for directory creation
DATE2=`date +%m%d%y%H%M%S`
# Start a new search in the log files
print "" > logs/recovery.log
print "New Search Started on ${DATE}" >> logs/recovery.log
# User Prompting for email, start date and end date
print " Welcome to the MRR User Recovery Interface"
print ""
print ""
print " Please enter the email address to search for:"
read user
print ""
print " Enter start date to search:"
read sdate
print ""
print "Enter end date of search:"
read edate
print ""
print "I will now search for the email from $user"
print "starting at $sdate and ending at $edate."
print ""
print ""
print "${DATE} Search context email $user" >> logs/recovery.log
print "${DATE} Starting date $sdate" >> logs/recovery.log
print "${DATE} Ending date $edate" >> logs/recovery.log
# Eventually there will be some stuff here to sort the zip files by the sdate and edate and then copy them off to a work directory.
 
# grab a list of the zip files. 
print "Now Getting a file list..."
# The following needs to be changed when putting into production. These file paths
# will *NOT* work. Make sure they are correct! You've been warned.
cd /home/chris/MRR/test/
ls *.zip > /home/chris/MRR/ziplist
print "${DATE} ziplist created" >> /home/chris/MRR/scripts/logs/recovery.log
# This is just for testing purposes, remove or comment out the following line
# cd ../scripts/
# cat ziplist
# Unzipping the files
# To do this, we need to feed the file into an array otherwise ksh will choke.
cat /home/chris/MRR/ziplist|sed 's/.\{4\}$//' >> /home/chris/MRR/dirlist
set -A dirlist $(< /home/chris/MRR/dirlist)
set -A zipfile $(< /home/chris/MRR/ziplist)
for i in $zipfile
do
unzip -qq -d /home/chris/MRR/test/"$dirlist" /home/chris/MRR/test/"$zipfile" >> /home/chris/MRR/scripts/logs/recovery.log 
print "name of files in zipfile:" ${zipfile[*]}
done
#

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0