Re: Zip file making issues

2010-09-20 Thread Matt Emmerton


- Original Message - 
From: Ryan Coleman edi...@d3photography.com

To: FreeBSD Questions freebsd-questions@freebsd.org
Sent: Monday, September 20, 2010 11:11 PM
Subject: Zip file making issues


Does anyone have any advice for this?

I'm working on a series of commands - executed in a shell script - that zips 
a deep directory in a tree. But it makes the full path as part of the ZIP 
file. That's not what I want - I just want those directories that appear 
after the *.  In this case:


-J eliminates all the paths - bad because it also kills those after the 
*


Here's my default that includes the whole d*mn path.
/usr/local/bin/zip -r 
/usr/www/d3photography.com/htdocs/images/paidphotos/1284343047-Le-ach.zip 
/mount/archive/orders/Sep20/1284343047-Le-ach/download*


I could just run a cd to the directory parent and do it there - that would 
solve the problem - but that's simply too dangerous if the script generator 
throws an error on the next set of commands (a risk I do not want to take).


So how do I get it to store as download/small/image.jpg inside of the ZIP 
file instead of 
mount/archive/orders/Sep20/1284343047-Le-ach/download/small/image.jpg.


I only recently discovered this bug -- none of my clients have had the guts 
to tell me about it.


==

Just change the directory before you start zipping.

cd /mount/archive/orders/Sep20/1284343047-Le-ach
/usr/local/bin/zip -r 
/usr/www/d3photography.com/htdocs/images/paidphotos/1284343047-Le-ch.zip 
download*


--
Matt Emmerton 


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Zip file making issues

2010-09-20 Thread Ryan Coleman


On Sep 20, 2010, at 10:32 PM, Matt Emmerton wrote:

 
 - Original Message - From: Ryan Coleman edi...@d3photography.com
 To: FreeBSD Questions freebsd-questions@freebsd.org
 Sent: Monday, September 20, 2010 11:11 PM
 Subject: Zip file making issues
 
 
 Does anyone have any advice for this?
 
 I'm working on a series of commands - executed in a shell script - that zips 
 a deep directory in a tree. But it makes the full path as part of the ZIP 
 file. That's not what I want - I just want those directories that appear 
 after the *.  In this case:
 
 -J eliminates all the paths - bad because it also kills those after the *
 
 Here's my default that includes the whole d*mn path.
 /usr/local/bin/zip -r 
 /usr/www/d3photography.com/htdocs/images/paidphotos/1284343047-Le-ach.zip 
 /mount/archive/orders/Sep20/1284343047-Le-ach/download*
 
 I could just run a cd to the directory parent and do it there - that would 
 solve the problem - but that's simply too dangerous if the script generator 
 throws an error on the next set of commands (a risk I do not want to take).
 
 So how do I get it to store as download/small/image.jpg inside of the ZIP 
 file instead of 
 mount/archive/orders/Sep20/1284343047-Le-ach/download/small/image.jpg.
 
 I only recently discovered this bug -- none of my clients have had the guts 
 to tell me about it.
 
 ==
 
 Just change the directory before you start zipping.
 
 cd /mount/archive/orders/Sep20/1284343047-Le-ach
 /usr/local/bin/zip -r 
 /usr/www/d3photography.com/htdocs/images/paidphotos/1284343047-Le-ch.zip 
 download*

As I said in my OP: I could just run a cd to the directory parent and do it 
there - that would solve the problem - but that's simply too dangerous if the 
script generator throws an error on the next set of commands (a risk I do not 
want to take).

Thank you, though. I'm hoping to find a solution instead with PHP. One of these 
generated files comes out of PHP in a different directory path where a change 
of directory is not possible.

--
Ryan___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Zip file making issues

2010-09-20 Thread Michael Ross

Am 21.09.2010, 05:53 Uhr, schrieb Ryan Coleman edi...@d3photography.com:




As I said in my OP: I could just run a cd to the directory parent and  
do it there - that would solve the problem - but that's simply too  
dangerous if the script generator throws an error on the next set of  
commands (a risk I do not want to take).


Maybe you could:

mount -t nullfs -o ro /where/my/data/is /mnt
cd /mnt
zip ...



Regards,

Michael
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Zip file making issues

2010-09-20 Thread Ryan Coleman
On Sep 20, 2010, at 11:14 PM, Michael Ross wrote:

 Am 21.09.2010, 05:53 Uhr, schrieb Ryan Coleman edi...@d3photography.com:
 
 
 
 As I said in my OP: I could just run a cd to the directory parent and do 
 it there - that would solve the problem - but that's simply too dangerous if 
 the script generator throws an error on the next set of commands (a risk I 
 do not want to take).
 
 Maybe you could:
 
 mount -t nullfs -o ro /where/my/data/is /mnt
 cd /mnt
 zip ...

Excellent suggestion. I have a PHP possibility I am going to try... and if that 
fails I think this will be the likely resolution for at least the shell script 
(although this still doesn't fix the PHP run command - I'll deal with that 
later I guess)

--
Ryan___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Zip file making issues

2010-09-20 Thread Matthew Seaman
On 21/09/2010 04:53:58, Ryan Coleman wrote:
 As I said in my OP: I could just run a cd to the directory parent
 and do it there - that would solve the problem - but that's simply
 too dangerous if the script generator throws an error on the next set
 of commands (a risk I do not want to take).

Um changing directory *is* the way to solve this.  Really.

What you can do in a shell script is work in a sub-shell: that way,
even if your zip command goes bananas, you are automatically returned to
your original working directory.  To create a sub-shell, just enclose
your commands in (brackets).

   (
  cd /mount/archive/orders/Sep20/1284343047-Le-ach/ ;
  zip -r
/usr/www/d3photography.com/htdocs/images/paidphotos/1284343047-Le-ach.zip \
  download*
   )

Cheers,

Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.   7 Priory Courtyard
  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
JID: matt...@infracaninophile.co.uk   Kent, CT11 9PW



signature.asc
Description: OpenPGP digital signature


Re: Zip file making issues

2010-09-20 Thread Ryan Coleman
That changing of directories doesn't solve the PHP script I have building ZIP 
files, though, with a single shell command (path/to/zip /path/to/zip.zip -r 
/path/to/folder/to/zip).

But I have solved this now with another PHP script that I can call both as part 
of my Apache CGI but also as a CLI.

 I just have to implement it which I will do in the morning.

--
Ryan

On Sep 21, 2010, at 12:14 AM, Matthew Seaman wrote:

 On 21/09/2010 04:53:58, Ryan Coleman wrote:
 As I said in my OP: I could just run a cd to the directory parent
 and do it there - that would solve the problem - but that's simply
 too dangerous if the script generator throws an error on the next set
 of commands (a risk I do not want to take).
 
 Um changing directory *is* the way to solve this.  Really.
 
 What you can do in a shell script is work in a sub-shell: that way,
 even if your zip command goes bananas, you are automatically returned to
 your original working directory.  To create a sub-shell, just enclose
 your commands in (brackets).
 
   (
  cd /mount/archive/orders/Sep20/1284343047-Le-ach/ ;
  zip -r
 /usr/www/d3photography.com/htdocs/images/paidphotos/1284343047-Le-ach.zip \
  download*
   )
 
   Cheers,
 
   Matthew
 
 -- 
 Dr Matthew J Seaman MA, D.Phil.   7 Priory Courtyard
  Flat 3
 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
 JID: matt...@infracaninophile.co.uk   Kent, CT11 9PW
 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org