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 > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Zipping dreams5617 UNIX for Dummies Questions & Answers 1 02-11-2007 08:03 PM
Limitations of a file size for zipping ramky79 AIX 1 01-19-2007 10:23 PM
zipping in a loop kotasateesh Shell Programming and Scripting 2 01-10-2007 08:14 AM
Zipping the dir dreams5617 Shell Programming and Scripting 1 07-26-2006 12:20 AM
zipping across platforms MizzGail UNIX for Dummies Questions & Answers 8 05-19-2005 01:01 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-09-2007
Jolly Jolly is offline
Registered User
  
 

Join Date: May 2007
Posts: 8
Question Help me While zipping the file

Hi ,

I have written code which will ask the subject,body of the mail, attachment and mail id of the receipient.
Code will pick up 4 files zip it. It will zip all the files and then post the mail to the receipient. While zipping the file i am getting error. Can anyone help me with this.

#!/bin/Sh

##Parameters to be passed
echo 'What subject do you want to put for mail'
read subject

echo 'Pass the path of the text file containing the body of the mail'
read body

echo 'Pass the path of the files need to be attached'
read attachment_path

echo 'Pass the mail id'
read mail_receiver


##Start of Program
cd $attachment_path
echo 'current path is' `pwd`


## Count and initialize parameters
count=`ls|wc -l`
echo 'count is '$count
a=0


##introduced while loop to pick up the first 4 files and zip. Delete the files that are already zipped and pick the other file
## to be zipped

while [ $count -gt 0 ]
do
ls|head -4 > zipfiles
cat zipfiles
sed - e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/AbcdeFghIjklmnopqRstuvwxyz/' -e "s/^/\'/" -e "s/$/\'/" <zipfiles> zfile

list_of_file=`cat zfile`
echo $list_of_file

a=`expr $a + 1`
zip Snaps[$a] $list_of_file
rm $list_of_file
count=0
echo 'Files zipped'
rm zfile
done

## This block send the mail to the receiver.
file=`ls`
echo 'count of zip file -' $file
for i in $file
do
echo $i
var=$i
( cat $body
uuencode $var $var
) | mailx -s "$subject" ${mail_receiver}

done
***************************------**********************

While Executing this I am getting error :

current path is /export/home/jmirani/MAILExample/attach
count is 120
First month of RIA 001.jpg
First month of RIA 002.jpg
First month of RIA 003.jpg
First month of RIA 004.jpg
'First month of RIA 001.jpg' 'First month of RIA 002.jpg' 'First month of RIA 003.jpg' 'First month of RIA 004.jpg'
mail.sh[57]: 'First: not found

zip error: Nothing to do! (Snaps[1].zip)
'First: No such file or directory
month: No such file or directory
of: No such file or directory
RIA: No such file or directory
001.jpg': No such file or directory
'First: No such file or directory
month: No such file or directory
of: No such file or directory
RIA: No such file or directory
002.jpg': No such file or directory
'First: No such file or directory
month: No such file or directory
of: No such file or directory
RIA: No such file or directory
003.jpg': No such file or directory
'First: No such file or directory
month: No such file or directory
of: No such file or directory
RIA: No such file or directory
004.jpg': No such file or directory
Files zipped


All though files have been put into string still zip takes the wrong file name. Any help with this is much appreciated.

I tried zip trial 'First month of RIA 001.jpg' 'First month of RIA 002.jpg' 'First month of RIA 003.jpg' 'First month of RIA 004.jpg'
and this works properly.But code doesn't work?
  #2 (permalink)  
Old 05-09-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
It is very hard to to work with filenames that contain embedded blanks. The files are broken up by the spaces. You will need to arrange for each file name to be surrounded by quotes.
  #3 (permalink)  
Old 05-10-2007
Jolly Jolly is offline
Registered User
  
 

Join Date: May 2007
Posts: 8
I have already arrange the files surrounded by quote, but for some reason it is giving error while zipping the files. I have also provided the results with the problem occuring.
  #4 (permalink)  
Old 05-10-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
I treied your script. I don't know how it got it run like that. I had to fix the sed statement. You have:
sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/AbcdeFghIjklmnopqRstuvwxyz/' -e "s/^/\'/" -e "s/$/\'/"
that first "- e" should not have a space between the - and the e. I didn't have zip, so I chaged it to "ls -l" for testing. At first I got the same errors as you. But then this worked:
eval ls -l $list_of_file
  #5 (permalink)  
Old 05-10-2007
Jolly Jolly is offline
Registered User
  
 

Join Date: May 2007
Posts: 8
space in sed was my copy paste mistake.

I am also doinf echo before zipping and i am getting :
'First month of RIA 001.jpg' 'First month of RIA 002.jpg' 'First month of RIA 003.jpg' 'First month of RIA 004.jpg'

Every file is surrounded by quotes and should be picked up correctly while zipping but not getting picked.

Can someone help mw with why zip command is not picking up the files peoperly.

I tried this maually

zip <ZIPFILENAME> 'First month of RIA 001.jpg' 'First month of RIA 002.jpg' 'First month of RIA 003.jpg' 'First month of RIA 004.jpg'

above commna dworked properly and created <ZIPFILENAME>.zip

Help HelpHelp!!!!!!!!
  #6 (permalink)  
Old 05-10-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
If you won't try "eval" there is no point in trying to help you.
  #7 (permalink)  
Old 05-10-2007
Jolly Jolly is offline
Registered User
  
 

Join Date: May 2007
Posts: 8
I am more than happy to try eval, unfortunately don't know what and where should i put this to get the result i am expecting.

I have read the help of eval command, but since eval doesn't zip the file , i haven't tried it.

Can you put the command in the appropriate place of the script i have pasted, and i will be more than happy to try this.

Sorry for any inconvenience caused.
Sponsored Links
Closed Thread

Bookmarks

Tags
mailx, mailx attachment

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 05:35 AM.


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