From: Murray R. Van Luyn. on

"Sidney Lambe" <sidneylambe(a)nospam.invalid> wrote in message
news:slrnhjp8k7.pga.sidneylambe(a)evergreen.net...
> On comp.unix.shell, Murray R. Van Luyn. <valid(a)email.address>
> wrote:
>
>> "Sidney Lambe" <sidneylambe(a)nospam.invalid> wrote in message
>> news:slrnhjp5lc.pga.sidneylambe(a)evergreen.net...
>>
>>> On comp.unix.shell, houghi <houghi(a)houghi.org.invalid> wrote:
>>>
>>>> Murray R. Van Luyn. wrote:
>>>>
>>>>> Okay, can any sneaky shell gurus think of a single command
>>>>> line that unzips the files, pipes them through touch, and
>>>>> then pipes the results to zip to replace the original
>>>>> archive?
>>>>
>>>> What is the reason it must be a oneliner? Just curious.
>>>
>>> Good question. If, for some weird reason, there can't be any
>>> newlines within the script, he can use semi-colons instead.
>>>
>>> line 1 ; line 2 ; line 3 ...
>>>
>>> Sid
>>>
>>
>>
>> Hi Sidney,
>>
>> Ah, that's one solution I hadn't thought of, but is interesting
>> to note. Thanks for that useful tip.
>>
>> Yeah, it's really the elegance of piping whole files that I'm
>> most curious about.
>>
>> Muz.
>>
>>
>
> I can relate to that, Murray, but I think you better choose
> something other than touch for your experiments, because
> I don't think it takes piped input.
>
> Here's a couple of relevant scripts you might find enlightening.
> They are used to send a bunch of files to a remoted machine
> using netcat (nc). "1234" is the port number:
>
> Send tar cfp - /some/dir | compress -c | nc -w 3 othermachine 1234
>
>
> Receive nc -l -p 1234 | uncompress -c | tar xvfp -
>
>
> Sid
>
>

Hi Sidney,

Thanks very much for the good examples of piping files that you posted. Yes,
that's the sort of thing I was hoping to achieve, yet with different
commands.

Hmm...I've played with the -p option for unzip and the - option for zip long
enough tonight, and I'm no closer to the objective. If it's not immediately
obvious to anyone what I'm trying to achieve, then I might suggest that it's
not worth anyone particularly bothering with. I'll just use the conventional
series of commands solution instead of holding out for an elegant and
unnecessary 'one liner'.

Thanks again for all suggestions and feedback, guy's. Very much appreciated!

Muz.


From: mop2 on
On Thu, 31 Dec 2009 12:42:31 -0200, Murray R. Van Luyn. <valid(a)email.address> wrote:

> Hmm...I've played with the -p option for unzip and the - option for zip long
> enough tonight, and I'm no closer to the objective. If it's not immediately
> obvious to anyone what I'm trying to achieve, then I might suggest that it's
> not worth anyone particularly bothering with. I'll just use the conventional
> series of commands solution instead of holding out for an elegant and
> unnecessary 'one liner'.
>

The touch command is for "files", then you need files to touch them.
You can think about a substitution of the string time of the file transiting across the pipe,
but the job is complex, unless you find one tool done to this purpose.

If you already do the task, you know how.
Put these commands in a function and all is solved.

For example:

rezip(){
[ $1 ]&&[ -e $1]||return

#here you list your comands...
mkdir tmp
cd tmp
unzip $1
touch files
rezip

rename zip file
remove tmp dir
if all is ok remove old zipfile
etc...

}

#Now you have a very small and elegant one liner:


rezip file.zip

#if you prefer create a micro script instead a function, no problem...

You can do things as that to all your repetitive and tediously tasks.
From: OldSchool on
On Dec 31, 7:21 am, "Murray R. Van Luyn." <va...(a)email.address> wrote:
> "houghi" <hou...(a)houghi.org.invalid> wrote in message
>
> news:slrnhjp2n1.u03.houghi(a)penne.houghi...
>
> > Murray R. Van Luyn. wrote:
> >> Okay, can any sneaky shell gurus think of a single command line that
> >> unzips
> >> the files, pipes them through touch, and then pipes the results to zip to
> >> replace the original archive?
>
> > What is the reason it must be a oneliner? Just curious.
>
> > houghi
> > --
> > If you owe the bank $100 that's your problem.
> > If you owe the bank $100 million, that's the bank's problem.
> > If you owe the bank $700 billion, it becomes your problem again.
>
> Hi houghi,
>
> That I wish to perform the task as a 'one liner' is purely of academic
> interest. I'm just curious about how the piping mechanism works, and whether
> it can be used to pass whole files between programs.
>
> Muz.

you need to differentiate between the "contents of files" and the and
the information kept in the inode/disk structures associated with the
file names (mtime,ctime....). "touch" manipulates the later, not the
former.

pipes can pass the entire contents of a file, but the time stamps
aren't part of that information. that being the case, "touch"ing the
piped contents won't alter the dates associate with the files
From: Murray R. Van Luyn. on

"mop2" <invalid(a)mail.address> wrote in message news:op.u5s6tbo0f8ly3v(a)k7...
> On Thu, 31 Dec 2009 12:42:31 -0200, Murray R. Van Luyn.
> <valid(a)email.address> wrote:
>
>> Hmm...I've played with the -p option for unzip and the - option for zip
>> long
>> enough tonight, and I'm no closer to the objective. If it's not
>> immediately
>> obvious to anyone what I'm trying to achieve, then I might suggest that
>> it's
>> not worth anyone particularly bothering with. I'll just use the
>> conventional
>> series of commands solution instead of holding out for an elegant and
>> unnecessary 'one liner'.
>>
>
> The touch command is for "files", then you need files to touch them.
> You can think about a substitution of the string time of the file
> transiting across the pipe,
> but the job is complex, unless you find one tool done to this purpose.
>
> If you already do the task, you know how.
> Put these commands in a function and all is solved.
>
> For example:
>
> rezip(){
> [ $1 ]&&[ -e $1]||return
>
> #here you list your comands...
> mkdir tmp
> cd tmp
> unzip $1
> touch files
> rezip
>
> rename zip file
> remove tmp dir
> if all is ok remove old zipfile
> etc...
>
> }
>
> #Now you have a very small and elegant one liner:
>
>
> rezip file.zip
>
> #if you prefer create a micro script instead a function, no problem...
>
> You can do things as that to all your repetitive and tediously tasks.

Hi Mop2,

Well, I've definitely struck the right newsgroup for this one. Thanks very
much for providing your solution to my query, mop2..

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. I've lost tens of thousands of dollars in sales as a
result of people uploading my code to 'free' software download sites. It's
next to impossible to get software removed from circulation once it's there,
but if I can trace uploaded files to an individual abuser, then maybe
there's a shot at claiming compensation for the losses.

> 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");

Anyway, thanks very much for taking the time to answer my query, mop2. This
is certainly a very gentlemanly and helpful newsgroup.

Muz.


From: Murray R. Van Luyn. on

"OldSchool" <scott.myron(a)macys.com> wrote in message
news:b0806555-acaa-4001-8ed5-e4358078df5a(a)k19g2000yqc.googlegroups.com...
On Dec 31, 7:21 am, "Murray R. Van Luyn." <va...(a)email.address> wrote:
> "houghi" <hou...(a)houghi.org.invalid> wrote in message
>
> news:slrnhjp2n1.u03.houghi(a)penne.houghi...
>
> > Murray R. Van Luyn. wrote:
> >> Okay, can any sneaky shell gurus think of a single command line that
> >> unzips
> >> the files, pipes them through touch, and then pipes the results to zip
> >> to
> >> replace the original archive?
>
> > What is the reason it must be a oneliner? Just curious.
>
> > houghi
> > --
> > If you owe the bank $100 that's your problem.
> > If you owe the bank $100 million, that's the bank's problem.
> > If you owe the bank $700 billion, it becomes your problem again.
>
> Hi houghi,
>
> That I wish to perform the task as a 'one liner' is purely of academic
> interest. I'm just curious about how the piping mechanism works, and
> whether
> it can be used to pass whole files between programs.
>
> Muz.

you need to differentiate between the "contents of files" and the and
the information kept in the inode/disk structures associated with the
file names (mtime,ctime....). "touch" manipulates the later, not the
former.

pipes can pass the entire contents of a file, but the time stamps
aren't part of that information. that being the case, "touch"ing the
piped contents won't alter the dates associate with the files


Hi OldSchool,

Yes, I'm starting to see the difference. Had I persevered with zip and
unzip, then I might have managed to pipe decompressed files straight back
into zip for re-compression (?). Touch appears not to be a suitable
candidate for interstitial processing, however. Never mind. I can quite
happily go the multi-statement command sequence route instead.

Thanks also for your perspective of the situation, OldSchool. I'm very
pleased to have found a very helpful group with lots of good ideas to share.

Muz.