Page 1 of 1

ZIP files using Execute command stage

Posted: Mon Apr 05, 2010 5:22 am
by jreddy
I have a job sequence, that has a series of jobs to write to set of files and then one execute command stage to zip them up (in LInux) with this command

zip -r #TgtFileLoc#/Files.zip #TgtFileLoc#/*

And then another notification activity to read this zip file and email it as an attachment. All of this works and i am able to receive the email with the zip file.

but issue is that when i try to look at the contents of the zip file, it has the complete folder structure of the #TgtFileLoc# - instead of it having just the different files. How to avoid this?

Thanks in advance for your suggestions.

Posted: Mon Apr 05, 2010 7:01 am
by chulett
Perhaps you should consider not using the "-r" option? That is, after all, what it does. :wink:

Posted: Mon Apr 05, 2010 7:17 am
by jreddy
Thanks Craig,
I did remove the -r but the output zip file still remains the same - i wonder why then.

Posted: Mon Apr 05, 2010 7:31 am
by chulett
Hmmm... if that's the default then perhaps using "-R" would make it do what you want. Note that's an upper-case R rather then the lower-case one you were using originally.

Posted: Mon Apr 05, 2010 7:50 am
by jreddy
it gave me an error with the -R

"zip error: Nothing to do! "

Posted: Mon Apr 05, 2010 8:04 am
by ulab
I suggest you try gzip command, it will work fine instead of zip in Unix/linux

Posted: Mon Apr 05, 2010 8:16 am
by jreddy
Balu,
the reason i need ZIP is coz these are csv files that i have generated on LInux, but need to email them to users who will open them in windows.

The zipped file when extracted looks good, i can open it fine in windows. The only issue what i am having here is that when i try to extract the zip file i am seeing the entire path

For eg: if the Target file location was
/folder1/folder2/Zipfile.zip, then when i extract, it extracts the same way
with all that folder structure - which is what i do not want.

Posted: Mon Apr 05, 2010 8:23 am
by chulett
Damn, not what I thought you meant. You need to 'cd' to the directory first and then do a relative zip if you don't want to store the full path. That or deselect the option to use the full path when unzipping. Do a "zip -help" from the command line and see if other options exist for this.

Posted: Mon Apr 05, 2010 8:30 am
by jreddy
Craig,
If i don't do a "cd" where will the zip file be created. i can take it from there as well but when i ran with

zip zipfile.zip #TgtLoc#/*

then it executed fine, just didnt know where it created that zip file - i didnt see it in $HOME or $DSHOME or /tmp

Posted: Mon Apr 05, 2010 8:50 am
by jreddy
OK - i think i see where it writes the zip file by default - its in the Project directory.

Posted: Mon Apr 05, 2010 9:12 am
by jreddy
I think this is what made this work

zip -j #TgtLoc#/ZipFile.zip #TgtLoc#/*

Thanks to all for your suggestions. Appreciate your time.

Posted: Mon Apr 05, 2010 9:02 pm
by chulett
If you don't specify a full path, it will write the output to the "current working directory", which for any job is the Project it is running from as you've found. To 'cd' first:

Code: Select all

cd #TgtLoc# && zip -j ZipFile.zip *