Unzip, copy, and delete loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unzip, copy, and delete loop
# 1  
Old 03-06-2007
Unzip, copy, and delete loop

Hey there,

I am trying to move zipped text files from a remote server to a remote tape storage facility, through my home directory. What I want to do is get the zip file (using scp), unzip it, copy the output text file which was inside (using rfcp) to the tape storage server, and then delete them both from my home.
The problem is I can't find a way to redirect the output of the 'unzip' command (aka the text file) to use it for other commands.
Here is what I came up with :
Code:
#!/bin/sh
cat list-zip.dat | \
while read filename1
do
	echo "Variable filename is set to $filename1..."

	# Copy the zip file from the server
	scp lardcs@atlasgw:BUFFER-HV/$filename1 .

	# Here I want to unzip the file and put the                    
	# output text file as an argument for the rfcp command  
	
	# Copy the text file to the tape storage pool disk
	rfcp $filename2 /castor/cern.ch/atlas/LargFec/HighVoltage

	rm $filename1 # delete the zip file
	rm $filename2 # delete the text file
done

My list-zip.dat is a simple list of the zip files I've created using 'ls > list-zip.dat'

Any help will be much appreciated.

Thank you.

Last edited by spyne; 03-07-2007 at 01:23 PM.. Reason: not any
# 2  
Old 03-07-2007
No reply ?

Please someone help !
I'm sure somebody knows how to deal with my problem !
Thank you.
# 3  
Old 03-07-2007
Quote:
Originally Posted by spyne
Hey there,

I am trying to move zipped text files from a remote server to a remote tape storage facility, through my home directory. What I want to do is get the zip file (using scp), unzip it, copy the output text file which was inside (using rfcp) to the tape storage server, and then delete them both from my home.
The problem is I can't find a way to redirect the output of the 'unzip' command (aka the text file) to use it for other commands.
Here is what I came up with :
Code:
#!/bin/sh
cat list-zip.dat | \

You don't need the backslash.
You don't even need cat.

while IFS= read -r filename1
do
: ...
done < list-zip.dat

Quote:
Code:
while read filename1
do
	echo "Variable filename is set to $filename1..."

	# Copy the zip file from the server
	scp lardcs@atlasgw:BUFFER-HV/$filename1 .

	# Here I want to unzip the file and put the                    
	# output text file as an argument for the rfcp command  
	
	# Copy the text file to the tape storage pool disk
	rfcp $filename2 /castor/cern.ch/atlas/LargFec/HighVoltage

	rm $filename1 # delete the zip file
	rm $filename2 # delete the text file
done

My list-zip.dat is a simple list of the zip files I've created using 'ls > list-zip.dat'
Why don't you unzip the files in an empty directory and use a wildcard?
# 4  
Old 03-07-2007
Quote:
You don't need the backslash.
You don't even need cat.

while IFS= read -r filename1
do
: ...
done < list-zip.dat
Okay, didn't know that, I'll guess I'll use it.

Quote:
Why don't you unzip the files in an empty directory and use a wildcard?
I thought about that, the problem is the rfcp command, which does not support wildcards... It's a command used to copy files to a tape storage unit through a disk pool, and it was developped by people here at CERN.

Anyway through hardcore web-browsing I managed to solve my problem, I just did a "ls | grep stuff > file.dat" and read the file to feed the filename to the rfcp command. And it works !
Thanks again and see you around.
Cheers!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unzip the .zip file without using unzip utility in UNIX

I have .zip file, i want to list all the files archived in the zip file. unzip utility is not working for me in unix. Please help me resolve this issue Thanks ganesh. (3 Replies)
Discussion started by: Ganesh L
3 Replies

2. Shell Programming and Scripting

Loop folders, delete files, copy new ones

Folks, I am hopeful that you may be able to help me out with writing a script that can be run nightly (as cron?) to loop through all subfolders within the "/media" directory, delete all of the files in each of them, and then copy in all of the files from the "/home//sansa" directory to each of... (6 Replies)
Discussion started by: acraig
6 Replies

3. Shell Programming and Scripting

Loop to copy like files

Hi, I need to write a script that copies all .zip files in the subdirectories of ~100 folders. No clue how to write a loop that goes into each folder, searches for a .zip file, and copies it and extracts it to a unique location. I imagine something like cp -f /home/folder1/*.zip... (6 Replies)
Discussion started by: nez
6 Replies

4. Shell Programming and Scripting

unzip with subdirectorys - for loop

Hey! I have some problems with unzip special files in subdirectorys. These Bash unzip -j ./content.zip simages/062/06213/0621352.jpg -d ./images/ unzip -j ./content.zip simages/062/06213/0621356.jpg -d ./images/ unzip -j ./content.zip simages/062/06213/0621351.jpg -d ./images/ unzip -j... (3 Replies)
Discussion started by: loptr
3 Replies

5. Shell Programming and Scripting

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

6. Shell Programming and Scripting

Copy and Delete Question

I have a script to tar up some older files. It did a find and mv, but I had to change it to preserve the directory structure because some of the directories now have duplicate nameed files. I changed it to a find and copy, then added a find and remove. Is there a better way so I don't have to... (2 Replies)
Discussion started by: prismtx
2 Replies

7. Solaris

Delete and copy file(s) slowly(!?)

Hi all! I have to monitor space in V890 machine, Solaris 10 weekly, because there is Oracle DB on it with many datafiles which have been taken offline to make enough size. Sometime, one or more datafiles are big, they are 20GB, 40GB etc.. The problem I have encountered is the processing of... (5 Replies)
Discussion started by: trantuananh24hg
5 Replies

8. Shell Programming and Scripting

while loop to copy on failure

I'm trying to do an automated SCP (passwordless auth is already set up) from a bash script... My problem is that on the receiving end, the computer will sometimes NOT actually get my files. BUT if I loop enough times (by hand at the moment) calling an 'ls' on those files, I can see if the files... (2 Replies)
Discussion started by: jjinno
2 Replies

9. HP-UX

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

10. UNIX for Dummies Questions & Answers

Copy files from CD and Unzip

Hi, I've just installed solaris 9 onto a SPARC box and am connecting to the machine via a console cable using hyper terminal. Unfortunately i have not got a monitor so i'm having to do all my config using the command line (which i'm no good at) I'm trying to copy a patch cluster (ZIP) file... (1 Reply)
Discussion started by: AJD
1 Replies
Login or Register to Ask a Question