ZIP files using Execute command stage

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
jreddy
Premium Member
Premium Member
Posts: 202
Joined: Tue Feb 03, 2004 5:09 pm

ZIP files using Execute command stage

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Perhaps you should consider not using the "-r" option? That is, after all, what it does. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
jreddy
Premium Member
Premium Member
Posts: 202
Joined: Tue Feb 03, 2004 5:09 pm

Post by jreddy »

Thanks Craig,
I did remove the -r but the output zip file still remains the same - i wonder why then.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jreddy
Premium Member
Premium Member
Posts: 202
Joined: Tue Feb 03, 2004 5:09 pm

Post by jreddy »

it gave me an error with the -R

"zip error: Nothing to do! "
ulab
Participant
Posts: 56
Joined: Mon Mar 16, 2009 4:58 am
Location: bangalore
Contact:

Post by ulab »

I suggest you try gzip command, it will work fine instead of zip in Unix/linux
Ulab----------------------------------------------------
help, it helps you today or Tomorrow
jreddy
Premium Member
Premium Member
Posts: 202
Joined: Tue Feb 03, 2004 5:09 pm

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jreddy
Premium Member
Premium Member
Posts: 202
Joined: Tue Feb 03, 2004 5:09 pm

Post 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
jreddy
Premium Member
Premium Member
Posts: 202
Joined: Tue Feb 03, 2004 5:09 pm

Post by jreddy »

OK - i think i see where it writes the zip file by default - its in the Project directory.
jreddy
Premium Member
Premium Member
Posts: 202
Joined: Tue Feb 03, 2004 5:09 pm

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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 *
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply