From: mop2 on
On Thu, 31 Dec 2009 19:30:10 -0200, Murray R. Van Luyn. <valid(a)email.address> wrote:
> Golly, I know next to nothing about Unix shell commands. I'm just trying to
> get a zipfile download preparation script in PHP to work on my website. The
> idea is just to touch the payload timestamps of my zipfile downloads, as a
> means of having then uniquely traceable to individual microcontroller
> software purchasers.


>> rezip(){
>> [ $1 ]&&[ -e $1]||return
>
> I'm fascinated by this snippet, mop2. What sort of language is that function
> written in? I may have to resort to some form of function loaded shell
> script for my command sequence, as I'm having trouble getting PHP's exec()
> function to run 'zip' consistently. It might be handy if I could fire-off a
> shell script with something like exec("rezip file.zip");

That is a shell function.
Now what your need is more clear.

Well, for dating your files, your case is more simple. Your files can be stored
in a private directory and a script touch and zip them to a public directory, so:

####your script (for zipping) is just:

touch /files/tozip/yourprg-1.0.0/*

/usr/bin/zip < /files/tozip/yourprg-1.0.0 >/your/download/area/yourprg-1.0.0.zip

######

You only need control the condition of only one download per time stamp.

Your php interpreter can run a shell script (I think), as above, or perhaps just:

exec("line 1; line 2");

Sorry, I don't know nothing about php.


From: Bill Marcum on
On 2009-12-31, Murray R. Van Luyn. <valid(a)email.address> wrote:
>
>
>> rezip(){
>> [ $1 ]&&[ -e $1]||return
>
> I'm fascinated by this snippet, mop2. What sort of language is that function
> written in?

That's part of a shell function, written in POSIX shell language. It
could be bash or ksh or one of several other shells.
The function returns if the first argument is empty or isn't the name of
an existing file or directory. $1 should be in double quotes in case it
contains whitespace.

From: Murray R. Van Luyn. on

"mop2" <invalid(a)mail.address> wrote in message news:op.u5tpileof8ly3v(a)k7...
> On Thu, 31 Dec 2009 19:30:10 -0200, Murray R. Van Luyn.
> <valid(a)email.address> wrote:
>> Golly, I know next to nothing about Unix shell commands. I'm just trying
>> to
>> get a zipfile download preparation script in PHP to work on my website.
>> The
>> idea is just to touch the payload timestamps of my zipfile downloads, as
>> a
>> means of having then uniquely traceable to individual microcontroller
>> software purchasers.
>
>
>>> rezip(){
>>> [ $1 ]&&[ -e $1]||return
>>
>> I'm fascinated by this snippet, mop2. What sort of language is that
>> function
>> written in? I may have to resort to some form of function loaded shell
>> script for my command sequence, as I'm having trouble getting PHP's
>> exec()
>> function to run 'zip' consistently. It might be handy if I could fire-off
>> a
>> shell script with something like exec("rezip file.zip");
>
> That is a shell function.
> Now what your need is more clear.
>
> Well, for dating your files, your case is more simple. Your files can be
> stored
> in a private directory and a script touch and zip them to a public
> directory, so:
>
> ####your script (for zipping) is just:
>
> touch /files/tozip/yourprg-1.0.0/*
>
> /usr/bin/zip < /files/tozip/yourprg-1.0.0
> >/your/download/area/yourprg-1.0.0.zip
>
> ######
>
> You only need control the condition of only one download per time stamp.
>
> Your php interpreter can run a shell script (I think), as above, or
> perhaps just:
>
> exec("line 1; line 2");
>
> Sorry, I don't know nothing about php.
>
>

Hi Mop2,

Don't worry Mop2, I don't know nothing about PHP either. :-) The searchable
documentation and examples are fabulous, however, and inspired cut & paste
seems to get one a very long way.

Hmm...what I really need is to write a tiny shell script that can
iteratively work through a set of zip files, expanding, touching and
re-compressing the contents of each. The idea would be to call it with a PHP
command like exec("touchzipfilepayloads zipfile1.zip zipfile2.zip
zipfile3.zip");

I'll have to search for a simple shell script example that illustrates the
control structure required to process a command line specified list of zip
files. Once I have that, it will be a simple matter of substituting my
unzip, touch, zip, rm command sequence.

Gee, I hope the shell program 'zip' works a little better for me when called
from a shell script. Otherwise, I'm no better off. Golly, isn't it a
stimulating exercise, to battle through the maze of possible solutions and
dead-ends, and finally arrive at working result? I'm having too much fun!

Muz.


From: Murray R. Van Luyn. on

"Murray R. Van Luyn." <valid(a)email.address> wrote in message
news:vsednRKwVb5_NqDWnZ2dnUVZ_umdnZ2d(a)westnet.com.au...
>
> "mop2" <invalid(a)mail.address> wrote in message
> news:op.u5tpileof8ly3v(a)k7...
>> On Thu, 31 Dec 2009 19:30:10 -0200, Murray R. Van Luyn.
>> <valid(a)email.address> wrote:
>>> Golly, I know next to nothing about Unix shell commands. I'm just trying
>>> to
>>> get a zipfile download preparation script in PHP to work on my website.
>>> The
>>> idea is just to touch the payload timestamps of my zipfile downloads, as
>>> a
>>> means of having then uniquely traceable to individual microcontroller
>>> software purchasers.
>>
>>
>>>> rezip(){
>>>> [ $1 ]&&[ -e $1]||return
>>>
>>> I'm fascinated by this snippet, mop2. What sort of language is that
>>> function
>>> written in? I may have to resort to some form of function loaded shell
>>> script for my command sequence, as I'm having trouble getting PHP's
>>> exec()
>>> function to run 'zip' consistently. It might be handy if I could
>>> fire-off a
>>> shell script with something like exec("rezip file.zip");
>>
>> That is a shell function.
>> Now what your need is more clear.
>>
>> Well, for dating your files, your case is more simple. Your files can be
>> stored
>> in a private directory and a script touch and zip them to a public
>> directory, so:
>>
>> ####your script (for zipping) is just:
>>
>> touch /files/tozip/yourprg-1.0.0/*
>>
>> /usr/bin/zip < /files/tozip/yourprg-1.0.0
>> >/your/download/area/yourprg-1.0.0.zip
>>
>> ######
>>
>> You only need control the condition of only one download per time stamp.
>>
>> Your php interpreter can run a shell script (I think), as above, or
>> perhaps just:
>>
>> exec("line 1; line 2");
>>
>> Sorry, I don't know nothing about php.
>>
>>
>
> Hi Mop2,
>
> Don't worry Mop2, I don't know nothing about PHP either. :-) The
> searchable documentation and examples are fabulous, however, and inspired
> cut & paste seems to get one a very long way.
>
> Hmm...what I really need is to write a tiny shell script that can
> iteratively work through a set of zip files, expanding, touching and
> re-compressing the contents of each. The idea would be to call it with a
> PHP command like exec("touchzipfilepayloads zipfile1.zip zipfile2.zip
> zipfile3.zip");
>
> I'll have to search for a simple shell script example that illustrates the
> control structure required to process a command line specified list of zip
> files. Once I have that, it will be a simple matter of substituting my
> unzip, touch, zip, rm command sequence.
>
> Gee, I hope the shell program 'zip' works a little better for me when
> called from a shell script. Otherwise, I'm no better off. Golly, isn't it
> a stimulating exercise, to battle through the maze of possible solutions
> and dead-ends, and finally arrive at working result? I'm having too much
> fun!
>
> Muz.
>

Does this look rational to anyone?

#!/bin/sh

while [ $# -ge 1 ]; do
unzip ./Secure/$1 -d ./Secure/Temp > /dev/null 2>&1
touch ./Secure/Temp/* > /dev/null 2>&1
zip -j ./Secure/$1 ./Secure/Temp/* > /dev/null 2>&1
rm ./Secure/Temp/* > /dev/null 2>&1
shift
done

exit 0


Called with something like:

../touchzipfilepayloads zipfile1.zip zipfile2.zip zipfile3.zip

Muz.


From: Sidney Lambe on
On comp.unix.shell, Murray R. Van Luyn. <valid(a)email.address>
wrote:

> "Murray R. Van Luyn." <valid(a)email.address> wrote in message
> news:vsednRKwVb5_NqDWnZ2dnUVZ_umdnZ2d(a)westnet.com.au...
>
>> "mop2" <invalid(a)mail.address> wrote in message
>> news:op.u5tpileof8ly3v(a)k7...
>>
>>> On Thu, 31 Dec 2009 19:30:10 -0200, Murray R. Van Luyn.
>>> <valid(a)email.address> wrote:
>>>
>>>> Golly, I know next to nothing about Unix shell commands. I'm
>>>> just trying to get a zipfile download preparation script in
>>>> PHP to work on my website. The idea is just to touch the
>>>> payload timestamps of my zipfile downloads, as a means of
>>>> having then uniquely traceable to individual microcontroller
>>>> software purchasers.
>>>
>>>
>>>>> rezip(){ [ $1 ]&&[ -e $1]||return
>>>>
>>>> I'm fascinated by this snippet, mop2. What sort of language
>>>> is that function written in? I may have to resort to
>>>> some form of function loaded shell script for my command
>>>> sequence, as I'm having trouble getting PHP's exec()
>>>> function to run 'zip' consistently. It might be handy
>>>> if I could fire-off a shell script with something like
>>>> exec("rezip file.zip");
>>>
>>> That is a shell function Now what your need is more clear .
>>>
>>> Well, for dating your files, your case is more simple. Your
>>> files can be stored in a private directory and a script touch
>>> and zip them to a public directory, so:
>>>
>>> ####your script (for zipping) is just:
>>>
>>> touch /files/tozip/yourprg-1.0.0/*
>>>
>>> /usr/bin/zip < /files/tozip/yourprg-1.0.0
>>>
>>> >/your/download/area/yourprg-1.0.0.zip
>>>
>>> ######
>>>
>>> You only need control the condition of only one download per
>>> time stamp.
>>>
>>> Your php interpreter can run a shell script (I think), as
>>> above, or perhaps just:
>>>
>>> exec("line 1; line 2");
>>>
>>> Sorry, I don't know nothing about php.
>>>
>>
>>
>> Hi Mop2,
>>
>> Don't worry Mop2, I don't know nothing about PHP either.
>> :-) The searchable documentation and examples are fabulous,
>> however, and inspired cut & paste seems to get one a very long
>> way.
>>
>> Hmm...what I really need is to write a tiny shell script
>> that can iteratively work through a set of zip files,
>> expanding, touching and re-compressing the contents of
>> each. The idea would be to call it with a PHP command
>> like exec("touchzipfilepayloads zipfile1.zip zipfile2.zip
>> zipfile3.zip");
>>
>> I'll have to search for a simple shell script example that
>> illustrates the control structure required to process a
>> command line specified list of zip files. Once I have that, it
>> will be a simple matter of substituting my unzip, touch, zip,
>> rm command sequence.
>>
>> Gee, I hope the shell program 'zip' works a little better for
>> me when called from a shell script. Otherwise, I'm no better
>> off. Golly, isn't it a stimulating exercise, to battle through
>> the maze of possible solutions and dead-ends, and finally
>> arrive at working result? I'm having too much fun!
>>
>> Muz.
>
>

> Does this look rational to anyone?
>
> #!/bin/sh
>
> while [ $# -ge 1 ]; do
> unzip ./Secure/$1 -d ./Secure/Temp > /dev/null 2>&1
> touch ./Secure/Temp/* > /dev/null 2>&1
> zip -j ./Secure/$1 ./Secure/Temp/* > /dev/null 2>&1
> rm ./Secure/Temp/* > /dev/null 2>&1
> shift
> done
>
> exit 0
>
>
> Called with something like:
>
> ./touchzipfilepayloads zipfile1.zip zipfile2.zip zipfile3.zip
>
> Muz.
>
>

Looks like it would probably work. I don't know zip very
well.

(How come you are using what is essentially a Windows tool?
Why not tar?)

(> /dev/null 2>&1 instead of that, I use &> /dev/null.)

The thing to do is make some throwaway zip files and the
necessary dirs and test it.

Sid