You are here:  » How to unzip .zip feeds via CRON


How to unzip .zip feeds via CRON

Submitted by Convergence on Tue, 2012-06-19 21:56 in

v12/10B

Greetings,

Belong to one network that FTPs datafeeds directly to the /feeds/ folder with .zip extensions (merchantname.zip) - File names are consistent within the .zip file (merchantname.txt).

We currently use the following CRON to decompress all feeds in the /feeds/ folder then import:

cd /path/to/feeds/;gzip -f -d *.gz;/usr/bin/wget --max-redirect=9999 -O /dev/null "http://www.example.com/scripts/import_slow.php?password=xxxxxxx$&filename=@ALL"

What do we add, and where, to unzip the .zip files?

Sorry for being daft (long week already).

Thanks!

Submitted by support on Wed, 2012-06-20 11:21

Hi,

It should just be a case of including the unzip command inline - have a go with:

cd /path/to/feeds/;unzip *.zip;gzip -f -d *.gz;/usr/bin/wget --max-redirect=9999 -O /dev/null "http://www.example.com/scripts/import_slow.php?password=xxxxxxx$&filename=@ALL"

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Wed, 2012-06-20 16:24

Thank you, yet again, David!

Submitted by Convergence on Wed, 2012-06-20 17:35

Hi David,

However, unfortunately this did not work -

Any suggestions as to the possible problem?

Submitted by Convergence on Wed, 2012-06-20 20:50

Hi David,

Tried every which way but loose and still can't get it to work.

This is the error that appears at the top of the emailed CRON report:

Archive: MerchantNameA.zip
caution: filename not matched: MerchantNameB.zip
caution: filename not matched: MerchantNameC.zip
caution: filename not matched: MerchantNameD.zip
caution: filename not matched: MerchantNameE.zip
caution: filename not matched: MerchantNameF.zip
caution: filename not matched: MerchantNameG.zip

Thoughts?

Submitted by support on Thu, 2012-06-21 08:26

Hi,

Just looked into this and it would appear that the wildcard should be escaped with the backslash character in the command, e.g.

unzip \*.zip

This will pass the * into the unzip program; instead of being expanded out by the OS...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Thu, 2012-06-21 09:13

Hi David,

Thanks, again!

Question:

Any need to add -f to overwrite the existing feed?

And for giggles, what the heck is the -d flag for, LOL.

Thanks one more time!

Submitted by support on Thu, 2012-06-21 09:26

-d is "decompress" (gzip and gunzip are actually the same program!)

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Thu, 2012-06-21 20:33

Thanks,David!

Once we started playing around with flags we were able to get it to work.

One of our tests spit out the following in the CRON report, which we found quite helpful:

{content saved}

We went with -u in the command.

Did discover, unlike gzip, that the .zip file does not delete after being extracted.

Thanks, again!