The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Process wait time chandrakala.sg SUN Solaris 1 09-19-2007 01:04 AM
Perl: Run perl script in the current process vino Shell Programming and Scripting 10 12-09-2005 10:45 AM
Wait for Background Process to complete gozer13 Shell Programming and Scripting 3 02-14-2005 04:25 PM
Process Wait on DG UX fabbas UNIX for Dummies Questions & Answers 4 01-07-2004 06:56 AM
some process writin file - check if complete sade Filesystems, Disks and Memory 0 09-26-2003 08:46 AM

Closed Thread
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
  #1 (permalink)  
Old 04-16-2004
dangral dangral is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2002
Posts: 699
PERL: wait for process to complete

I'm using PERL on windows NT to try to run an extract of data. I have multiple zip files in multiple locations. I am extracting "*.t" from zip files and subsequently adding that file to one zip file so when the script is complete I should have one zip file with a whole bunch of ".t" files in it.

The problem comes after I extract the ".t" file and try to zip it up again, the file is not yet in the directory so zip cannot find the file. I have commented out the code beneath the zip command while testing the program.
Please help!

Code:

###Get generation directory information ###
open(GENDIR, "<gens.txt") or die "Can't open gens.txt $!";
while(<GENDIR>){
	chop($_);
	push(@gendirs,$_)
}	

## Unzip .t file into stage directory ##
for $i (0 .. $#gendirs){  
   	($gennum)=(split /\\G/, $gendirs[$i])[1];
	#print "$gennum\n";
	print "unzip -d \\stage -j $gendirs[$i]\\*.zip *.t\n";
	system("unzip -d \\stage -j $gendirs[$i]\\*.zip *.t");
##zip .t file ##
	system("zip -v -9 \\stage\\vista.zip ${gennum}.t");
	#open(GENS, "<listofGens.dat") or die "Can't open listofGens.dat $!";
	#while(<GENS>){
		#chop($_);
		#if ($_=~/^$gennum\|/){
			#($repname)=(split /\|/)[1];
			#print "$repname\n";
			#print "${gennum}.t";
			#print "\nrename \\stage\\${gennum}.t \\stage\\$repname\n";
			#system("rename stage\\${gennum}.t stage\\$repname");
			#last;
		#} 
		
	#}
	#close(GENS);
}





#open(GENS, "<listofGens.dat") or die "Can't open listofGens.dat $!";
#while(<GENS>){
#}
  #2 (permalink)  
Old 04-19-2004
Optimus_P Optimus_P is offline Forum Advisor  
flim flam flamma jamma
  
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
i have to ask a couple of questions.

1) if you comment out the zip portion do you see the files extracted to the proper directory?

2) why are you trying to zip it back up right after you unzip it? why dont you do all of your unziping then call your zip processes.

3) altho i havent worked with perl on windows i dont think you need to backslash the backslash in this case.

but at this point i would be makeing sure each portion of the script is doing what you want.

start w/ the unzip functions and makesure it is extracting your data to the correct directory.

then work on the zip portion. persaonly i would write 2 functions.

1 that unzips and 1 that zips; and i would do all the unziping first then do the zip.
  #3 (permalink)  
Old 04-21-2004
dangral dangral is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2002
Posts: 699
Thanks for the response. I've figured out the problem, which is not what I thought it was. The issue is that I did not specify the correct directory when zipping the files and thats why the zip program was complaining.

so...

Code:
system("zip -v -9 \\stage\\vista.zip ${gennum}.t");
should have been
Code:
system("zip -v -9 \\stage\\vista.zip \\stage\\${gennum}.t");
To answer your questions Optimus ( thanks for your suggestions which led me to the problem)...
1) Yes the files were extracted to the directory.
2) This method of zipping the files immediately after unzipping them is purely a space issue. I am dealing with thousands of text files, many of them are around .5GB unzipped. If I were to unzip all of them I would run out of disk space.
3) In my experience with windows and perl, you need either the double backslash or forward slash. There may be other ways to do it that I am not aware of.
Closed Thread

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 08:11 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