Mailinglist Archive: opensuse (1264 mails)

< Previous Next >
Re: [opensuse] Quick question: how to call a script function from "find"? - using parallel
On 2017-06-14 14:47, Vojtěch Zeisek wrote:
Dne středa 14. června 2017 14:25:59 CEST, Carlos E. R. napsal(a):
On 2017-06-14 13:53, Per Jessen wrote:
Carlos E. R. wrote:
find /home/cer/Fusion/Videos/ -type d | parallel parallel "sudo chown

one too many 'parallel's ? typo?

Oops.

Corrected, but still fails:

cer@Isengard:~/Fusion> time ./_Cambiar_permisos_Videos

To silence the citation notice: run 'parallel --bibtex'.

Run it to get rid of it. The author works at university (apparently) and he
gives money also according to how many other scientists appreciate his work
by
citing it in their scientific work.

chown: cannot access '/home/cer/Fusion/Videos/Buffy,\
cazavampiros/Temporada\ 7': No such file or directory chown: cannot access
'/home/cer/Fusion/Videos/Buffy,\ cazavampiros': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Major\ Crimes': No such file
or directory chown: cannot access '/home/cer/Fusion/Videos/Major\
Crimes/Temporada\ 5': No such file or directory ...
chown: cannot access '/home/cer/Fusion/Videos/Twin\ Peaks/Temporada\ 3': No
such file or directory /bin/bash: -c: line 0: unexpected EOF while looking
for matching `'' /bin/bash: -c: line 1: syntax error: unexpected end of
file
/bin/bash: -c: line 0: unexpected EOF while looking for matching `''
/bin/bash: -c: line 1: syntax error: unexpected end of file

You have mistyped some quotation (e.g. typographic quote instead of plain ").
It is not closed, BASH is confused, command fails. It can be caused by non-
standard character in the name of some directory.
Parallel prints output for particular line when everything is done (not to
overlap outputs of processing of more files). It obviously starts non-
interactive shells, so You can't get sudo prompt. If You run sudo right
before
(e.g. 'sudo echo') and then parallel, it'll remember the sudo authentication
(as when You run 'sudo X' and 'sudo Y' quickly).

I copied the quotes from the old, working, find --exec command. Anyway, I
pasted them again. Now I get:



Thousands of overflowing the display buffer:

Type: 'will cite' and press enter.

Run 'parallel --bibtex' just once.

I did. It said I would not get nagged again, but it is false.

Now I get:

cer@Isengard:~/Fusion> time ./_Cambiar_permisos_Videos
Academic tradition requires you to cite works you base your article on.
When using programs that use GNU Parallel to process data for publication
please cite:

@article{Tange2011a,
title = {GNU Parallel - The Command-Line Power Tool},
author = {O. Tange},
address = {Frederiksberg, Denmark},
journal = {;login: The USENIX Magazine},
month = {Feb},
number = {1},
volume = {36},
url = {http://www.gnu.org/s/parallel},
year = {2011},
pages = {42-47}
doi = {10.5281/zenodo.16303}
}

(Feel free to use \nocite{Tange2011a})

This helps funding further development; and it won't cost you a cent.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.

If you send a copy of your published article to tange@xxxxxxx, it will be
mentioned in the release notes of next version of GNU Parallel.


real 0m0.272s
user 0m0.222s
sys 0m0.063s
cer@Isengard:~/Fusion>

Notice how fast it finishes, that is impossible: it is not doing any work at
all. When sudo runs, I get tons of messages in the messages log, and with this
parallel thing I get none, so it is not running any command at all.

This is the script now:

#!/bin/bash

#find /home/cer/Fusion/Videos/ -type d \
# -exec sudo chown cer:cer '{}' \; \
# -exec chmod u+r+w+x,g+w+x,o+r-w-x,+t '{}' \; \
# -exec sudo chown cer-g:cer '{}' \; \
# -exec sudo setfacl -m u:wwwrun:rx '{}' \;

find /home/cer/Fusion/Videos/ -type d | parallel --bibtex "sudo chown cer:cer
'{}' && chmod u+r+w+x,g+w+x,o+r-w-x,+t '{}'' && sudo chown cer-g:cer '{}' &&
sudo setfacl -m u:wwwrun:rx '{}'"



So now I remove the "--bibtex" thing, and I get this instead:

cer@Isengard:~/Fusion> time ./_Cambiar_permisos_Videos
chown: cannot access '/home/cer/Fusion/Videos/Buffy,\ cazavampiros': No such
file or directory
chown: cannot access '/home/cer/Fusion/Videos/Major\ Crimes': No such file or
directory
chown: cannot access '/home/cer/Fusion/Videos/Buffy,\ cazavampiros/Temporada\
7': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Major\ Crimes/Temporada\ 5': No
such file or directory
chown: cannot access '/home/cer/Fusion/Videos/La\ Casa\ de\ Papel': No such
file or directory
chown: cannot access '/home/cer/Fusion/Videos/La\ Casa\ de\ Papel/Temporada\
1': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Crossing\ Jordan': No such file
or directory
chown: cannot access '/home/cer/Fusion/Videos/Crossing\ Jordan/Temporada\ 2':
No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Crossing\ Jordan/Temporada\ 1':
No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Ley\ y\ orden\ \ unidad\ de\
victimas\ especiales': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Ley\ y\ orden\ \ unidad\ de\
victimas\ especiales/Temporada\ 13': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Ley\ y\ Orden\ \ Unidad\ de\
Victimas\ Especiales': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Ley\ y\ orden\ \ unidad\ de\
victimas\ especiales/Temporada\ 14': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Ley\ y\ Orden\ \ Unidad\ de\
Victimas\ Especiales/Temporada\ 13': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Justified\ \ la\ ley\ de\
Raylan': No such file or directory
chown: cannot access '/home/cer/Fusion/Videos/Justified\ \ la\ ley\ de\
Raylan/Temporada\ 6': No such file or directory
^C
real 0m0.993s
user 0m1.778s
sys 0m0.482s
cer@Isengard:~/Fusion>


It is not handling correctly the spaces in the names. Forget commas, most of
the strings do not have them.

I think it is passing to chown this command line:

chown ... '/home/cer/Fusion/Videos/Major\ Crimes'

with quotes. See:


cer@Isengard:~/Fusion> ls '/home/cer/Fusion/Videos/Major\ Crimes'
ls: cannot access '/home/cer/Fusion/Videos/Major\ Crimes': No such file or
directory
cer@Isengard:~/Fusion>

So I change the script to:

find /home/cer/Fusion/Videos/ -type d | parallel "sudo chown cer:cer {} &&
chmod u+r+w+x,g+w+x,o+r-w-x,+t {} && sudo chown cer-g:cer {} && sudo setfacl -m
u:wwwrun:rx {} "


and this finally runs!

cer@Isengard:~/Fusion> time ./_Cambiar_permisos_Videos

real 0m3.881s
user 0m8.909s
sys 0m1.916s
cer@Isengard:~/Fusion>

There is some speed improvement.


--
Cheers / Saludos,

Carlos E. R.
(from 42.2 x86_64 "Malachite" at Telcontar)

< Previous Next >
Follow Ups