Re: script ocaml utilisant module Unix

2024-06-03 Thread didier gaumet

Le 03/06/2024 à 11:31, Basile Starynkevitch a écrit :

Bonjour la liste

Sur mon système Debian Testing j'ai

  % /usr/bin/ocaml --version
   The OCaml toplevel, version 4.14.1

Sans utiliser opam je voudrais améliorer dans 
https://github.com/RefPerSys/RefPerSys/commit/dbf79c52dafd6b26d028c407c7339d1645ad8479 le script Create-RefPerSys.ocaml pour que le module Unix soit chargé


(et seules les distributions Linux m'intéressent)

Comment faire?

Cordialement


Bonjour

Avertissement: je ne connais strictement rien à Ocalm

bien qu'il semble être possible d'installer Ocalm sans Opam (le 
gestionnaire de paquets sources d'Ocalm), ça semble aussi amener des 
difficultés ou dysfonctionnements d'après les entrefilets trouvés sur 
internet.
En tout cas l'installation minimale d'Ocalm telle que recommandée par le 
site Ocalm.org implique l'installation d'Opam comme étape préalable:

https://ocaml.org/docs/installing-ocaml

Les paquets sources Ocaml relatifs à Unix sont là:
https://ocaml.org/packages/search?q=unix
peut-être regarder du côté de core-unix et base-unix (simple 
supposition, ce n'est peut-être pas ça)


La doc sur les modules (si il s'agit bien de modules au sens Ocalm du 
terme) et la façon de les utiliser est là, tu trouveras peut-être (je 
n'ai pas lu) un indice sur comment faire sans Opam:

https://ocaml.org/docs/modules



[HS] assistance au code (Re: Script BASH gestion des espaces des noms de fichier)

2024-02-05 Thread Sébastien NOBILI

Bonjour,

Le 2024-02-05 16:07, Daniel Caillibaud a écrit :
Oui, et je vous encourage à passer vos shell bash à shellcheck, il 
signale ce genre d'erreur

(et plein d'autres).
Il est parfois un peut trop zélé, mais on peut lui dire qu'on sait ce 
qu'on fait avec du


  # shellcheck disable=SC

avant la ligne qui le fait râler (où  est le code d'erreur qu'il 
signale)


Avec Neovim, on peut avoir ce genre d'assistance en direct :)

Sébastien



Re: Script BASH gestion des espaces des noms de fichier

2024-02-05 Thread Daniel Caillibaud
Le 02/02/24 à 08:54, Jérémy Prego  a écrit :
> Pour éviter ce problème, on peut mettre les variables entre "
> 
> du coup, ça donnerai:
> 
> pdftk "$fichier1" stamp "$tampon" output "$fichier2"

Oui, et je vous encourage à passer vos shell bash à shellcheck, il signale ce 
genre d'erreur
(et plein d'autres).
Il est parfois un peut trop zélé, mais on peut lui dire qu'on sait ce qu'on 
fait avec du

  # shellcheck disable=SC

avant la ligne qui le fait râler (où  est le code d'erreur qu'il signale)

-- 
Daniel

La pensée vole et les mots vont à pied. Voilà tout le drame de l'écrivain.
Julien Green



Re: script/history

2024-02-04 Thread Gareth Evans
On Mon 05/02/2024 at 00:45, Greg Wooledge  wrote:
...
> If you're one of these "I want every command I ever run to be in my
> shell history, retained forever, and I don't care how much space it
> takes" people, then there are web pages out there that can help you.
> I don't follow that philosophy myself, so I can't give you specific
> variables and settings.  But Google can.

I find a long history useful, and have already googled for such, though I 
should perhaps rotate it at some point :)

Thanks for the detailed explanation.
G



Re: script/history

2024-02-04 Thread Gareth Evans
(Re)posting the below as requested, and can confirm 

history -r 

seems to have the desired effect.
Thanks.

- Original message -
From: Will Mengarini 
To: Gareth Evans 
Cc: debian-user@lists.debian.org
Subject: Re: script/history
Date: Monday, 5 February 2024 01:02

* Gareth Evans  [24-02/04=Su 09:46 +]:
> Re the script command, does anyone know of a way to make
> commands run during a script session appear in bash history too?

You want the 'history -r' command, "explained" by `help history`.

After you end the script, you're back in the bash instance you ran
'script' from.  When you ended the script & therefore the bash being run
in that script, that bash wrote its commands to ~/.bash_history; but
the bash you're running, which is the one you ran script from, hasn't
read that ~/.bash_history.  Running 'history -r' will cause it to do so.

BTW I've got some kind of email configuration problem that usually
prevents me from posting to debian-user, even though I can usually
email individual users.  Gareth, if you get this, and it's the correct
solution to your original problem, perhaps you could post it to the
list; this email is CCd to debian-user, but I expect the CC to bounce.



Re: script/history

2024-02-04 Thread Will Mengarini
* Gareth Evans  [24-02/04=Su 09:46 +]:
> Re the script command, does anyone know of a way to make
> commands run during a script session appear in bash history too?

You want the 'history -r' command, "explained" by `help history`.

After you end the script, you're back in the bash instance you ran
'script' from.  When you ended the script & therefore the bash being run
in that script, that bash wrote its commands to ~/.bash_history; but
the bash you're running, which is the one you ran script from, hasn't
read that ~/.bash_history.  Running 'history -r' will cause it to do so.

BTW I've got some kind of email configuration problem that usually
prevents me from posting to debian-user, even though I can usually
email individual users.  Gareth, if you get this, and it's the correct
solution to your original problem, perhaps you could post it to the
list; this email is CCd to debian-user, but I expect the CC to bounce.



Re: script/history

2024-02-04 Thread Greg Wooledge
On Mon, Feb 05, 2024 at 12:28:38AM +, Gareth Evans wrote:
> I was trying to view the history of commands run during a script session.
> 
> user@qwerty:~$ script foo
> Script started, output log file is 'foo'.
> user@qwerty:~$ date
> Mon  5 Feb 00:21:16 GMT 2024
> user@qwerty:~$ exit
> exit
> Script done.
> user@qwerty:~$ history |tail -n3
> 30914  2024-02-04 23:44:24  man script
> 30915  2024-02-05 00:21:15  script foo
> 30916  2024-02-05 00:21:25  history |tail -n3 # NB "date" is missing
> 
> Michael Grant pointed out (among other things) that the history is available, 
> but not in the terminal in which script has just exited.

OK.  Well, start by thinking about what happens if you're in a bash
shell, and you type "bash".  You get a second bash instance, which is a
child process of the original shell.  The original shell goes to sleep,
and waits for the child to exit.

When the child process starts up, it reads the .bash_history file (unless
you changed the variable that names the file), thereby loading the shell
history from disk into memory.  Then you run whatever commands you run,
and those are appended to the in-memory shell history.  Then you exit,
at which point bash rewrites the .bash_history file.

After exiting from the child shell, you're back in the original shell.
The original shell's in-memory history did not change during the child's
lifetime.  The only change to the in-memory history is the addition of
a "bash" command.  The .bash_history file has been changed, but the
running shell doesn't read that to get the new contents in memory.

If/when you exit from the original shell, the .bash_history file will
be rewritten again, using the in-memory history of the original bash
instance.  This does *not* include any changes that were written by
the child process.  Those changes may simply be lost.  It depends on
which history options you've chosen, and how many new commands were
appended to the original shell's in-memory history before exiting.

Once you understand all of this, then it should be obvious how "script"
works.  It runs a new instance of "bash".  As far as history goes, it
works exactly like the above.  The only difference is you've also got
a file containing a recording of the terminal session.

If you're one of these "I want every command I ever run to be in my
shell history, retained forever, and I don't care how much space it
takes" people, then there are web pages out there that can help you.
I don't follow that philosophy myself, so I can't give you specific
variables and settings.  But Google can.



Re: script/history

2024-02-04 Thread Gareth Evans
On Sun 04/02/2024 at 19:45, David Wright  wrote:
...
> According to this man page for csh (but includes tcsh):
>
>   https://linux.die.net/man/1/csh
>
> the "a" that modifies modifiers is a "[feature] of tcsh not found
> in most csh(1) implementations (specifically, the 4.4BSD csh)". It
> appears that bash supports it syntactically, but not its semantics.
> I'm not sure why you mentioned this shell detail specifically.

I was just highlighting a way to see if behaviour differs between bash "proper" 
and script running in bash.

cf.

"a (+)
Apply the following modifier as many times as possible to a single word ..."
https://linux.die.net/man/1/csh

"a
Cause changes to be applied over the entire event line ..."
https://www.gnu.org/software/bash/manual/bash.html#Word-Designators

Thanks
Gareth



Re: script/history

2024-02-04 Thread Gareth Evans
On Sun 04/02/2024 at 17:33, Greg Wooledge  wrote:
...
> The script(1) utility has NOTHING to do with running ordinary shell
> scripts.

I understand that.

I was trying to view the history of commands run during a script session.

user@qwerty:~$ script foo
Script started, output log file is 'foo'.
user@qwerty:~$ date
Mon  5 Feb 00:21:16 GMT 2024
user@qwerty:~$ exit
exit
Script done.
user@qwerty:~$ history |tail -n3
30914  2024-02-04 23:44:24  man script
30915  2024-02-05 00:21:15  script foo
30916  2024-02-05 00:21:25  history |tail -n3 # NB "date" is missing

Michael Grant pointed out (among other things) that the history is available, 
but not in the terminal in which script has just exited.

Meanwhile, I read man script and wondered if csh, or even just csh's approach 
to history manipulation, was somehow involved.

I was then a little surprised to see 

user@qwerty:~$ csh # bash prompt
% script foo   # csh prompt
Script started, output log file is 'foo'.
user@qwerty:~$ date# bash prompt in script in csh in bash
Sun  4 Feb 23:25:14 GMT 2024
user@qwerty:~$ exit
exit
Script done.
% exit
% exit
user@qwerty:~$ 

although on a "native" csh system, I would expect script to "present" csh, not 
bash.  I 

I am left with the impression that script may impose csh's history 
substitution/manipulation approach/syntax (for what differences there may be) 
regardless of which shell it's running from, and that that is the reason for 
the reference to csh for the "history mechanism" in man script.

Thanks
Gareth



Re: script/history

2024-02-04 Thread Greg Wooledge
On Sun, Feb 04, 2024 at 01:45:27PM -0600, David Wright wrote:
> SCRIPT(1) User Commands  SCRIPT(1)
> [ … ]
> HISTORY
>The script command appeared in 3.0BSD.
> 
> I have no idea why "the history mechanism" is even mentioned
> in the man page for script.

It appears in the FreeBSD man page as well, but not the OpenBSD man
page.

https://man.freebsd.org/cgi/man.cgi?script
https://man.openbsd.org/script

I don't understand why that parenthetical comment is in the FreeBSD
man page either, but it was clearly copied over to the util-linux
man page without modification.

Another thing I don't understand is what the OP of this thread was
trying to do in the first place.



Re: script/history

2024-02-04 Thread David Wright
On Sun 04 Feb 2024 at 16:01:29 (+), Gareth Evans wrote:
> On Sun 04/02/2024 at 13:24, Max Nikulin  wrote:
> > On 04/02/2024 16:46, Gareth Evans wrote:
> >> Re the script command, does anyone know of a way [ … ]
> > [...]
> >> man script says
> >> 
> >> "SEE ALSO
> >> csh(1) (for the history mechanism)"

My take on this is that the man page was originally written for
BSD, which lies on the csh side of the "great divide" rather
than the sh/bash side.

SCRIPT(1) User Commands  SCRIPT(1)
[ … ]
HISTORY
   The script command appeared in 3.0BSD.

I have no idea why "the history mechanism" is even mentioned
in the man page for script.

> The function of the "a" option in History Substitution in man csh seems 
> different in the bash version.(under "Word Designators" in man bash/gnu 
> online manual)

According to this man page for csh (but includes tcsh):

  https://linux.die.net/man/1/csh

the "a" that modifies modifiers is a "[feature] of tcsh not found
in most csh(1) implementations (specifically, the 4.4BSD csh)". It
appears that bash supports it syntactically, but not its semantics.
I'm not sure why you mentioned this shell detail specifically.

Cheers,
David.



Re: script/history

2024-02-04 Thread Greg Wooledge
On Sun, Feb 04, 2024 at 04:01:29PM +, Gareth Evans wrote:
> It seemed to me initially (as I should perhaps have stated) that man script 
> was suggesting that csh was a component or depedency (of script), which 
> seemed to be contradicted by it not being installed.  On reflection, 
> possibly, it's just a way of doing things in script.  The reference in man 
> script now seems to imply the latter.  
> 
> The fact that script scripts bash on my machine made me not think about the 
> fact that it probably scripts whatever shell it's running from, and was 
> doubtless written with one in mind/as inspiration - csh might make a certain 
> sense in that respect.  
> 
> script runs in bash if run from csh run from bash, but I suppose csh in that 
> chain of shells isn't a proper [do I mean login?] shell.  (Got that? :p)

You're so confused that I can't even figure out where to start!  So
let me start here:

The script(1) utility exists to RECORD a session so that you can play
it back later and see what happened.

One recommended use of this tool is to record the session in which you
do a dist-upgrade, say, from Debian 11 to Debian 12.  Then if anything
goes wrong, you can look back through the session's logfile and see
what happened, and try to fix it.

The script(1) utility has NOTHING to do with running ordinary shell
scripts.



Re: script/history

2024-02-04 Thread Gareth Evans
On Sun 04/02/2024 at 13:24, Max Nikulin  wrote:
> On 04/02/2024 16:46, Gareth Evans wrote:
>> Re the script command, does anyone know of a way to make commands run during 
>> a script session appear in bash history too?
> [...]
>> man script says
>> 
>> "SEE ALSO
>> csh(1) (for the history mechanism)"
>> 
>> but
>> 
>> $ man csh
>> No manual entry for csh
>
>  echo $SHELL
>
> If you really use BASH then install bash-doc, it contains manual in 
> various formats, including texinfo (info "bash") or read it online
> https://www.gnu.org/software/bash/manual/
> it describes some options related to history handling Actually "man 
> bash" is something rather close, but it does not allow to save links to 
> specific sections.

Hi Max,

Thanks for links and suggestions.

It seemed to me initially (as I should perhaps have stated) that man script was 
suggesting that csh was a component or depedency (of script), which seemed to 
be contradicted by it not being installed.  On reflection, possibly, it's just 
a way of doing things in script.  The reference in man script now seems to 
imply the latter.  

The fact that script scripts bash on my machine made me not think about the 
fact that it probably scripts whatever shell it's running from, and was 
doubtless written with one in mind/as inspiration - csh might make a certain 
sense in that respect.  

script runs in bash if run from csh run from bash, but I suppose csh in that 
chain of shells isn't a proper [do I mean login?] shell.  (Got that? :p)

The function of the "a" option in History Substitution in man csh seems 
different in the bash version.(under "Word Designators" in man bash/gnu online 
manual)

It'll be interesting to test when I can make sense of it :p

Anyway, my orginal question has been answered.

Thanks all.
Gareth



Re: script/history

2024-02-04 Thread hw
Oh you're right, I entirely overlooked the usage of 'script' and
didn't understand the question right, sorry.

On Sun, 2024-02-04 at 06:28 -0500, Michael Grant wrote:
> > $ script foo.txt
> > Script started, output log file is 'foo.txt'.
> > $ date
> > Sun  4 Feb 09:44:00 GMT 2024
> > $ exit
> > exit
> > Script done.
> > $ history|tail -n2
> > 30797  2024-02-04 09:43:57  script foo.txt
> > 30798  2024-02-04 09:44:21  history|tail -n2
> > 
> > I did try to search on this but just got lots of "bash history" and 
> > "history in
> > bash script" references.
> 
> So this might surprise you but the commands are actually in the
> history list!  But not in the current shell.
> 
> What happens is this:
> 
> You start 'script foo.txt' and this starts a sub bash shell on a
> different pseudo tty.  You run some commands, it appends each command
> to the history of this sub-shell's history.
> 
> You then exit your script.  Those commands you ran are at the bottom
> of .bash_history (try to cat that file out after you exit script and
> you should see them).
> 
> But those commands are not sucked into the history of your current
> shell.  Then, you log out (or exit) your current shell and the history
> of that shell overwrites the history of the previous one.
> 
> If all you want to do is save off the commands after you exit your
> script session, then simply move or copy .bash_history out of the way
> before it gets overwritten.
> 
> You might consider setting $HISTFILE to some other location other than
> .bash_history.
> 
> Michael Grant




Re: script/history

2024-02-04 Thread Max Nikulin

On 04/02/2024 16:46, Gareth Evans wrote:

Re the script command, does anyone know of a way to make commands run during a 
script session appear in bash history too?

[...]

man script says

"SEE ALSO
csh(1) (for the history mechanism)"

but

$ man csh
No manual entry for csh


echo $SHELL

If you really use BASH then install bash-doc, it contains manual in 
various formats, including texinfo (info "bash") or read it online

https://www.gnu.org/software/bash/manual/
it describes some options related to history handling Actually "man 
bash" is something rather close, but it does not allow to save links to 
specific sections.





Re: script/history

2024-02-04 Thread Greg Wooledge
On Sun, Feb 04, 2024 at 09:46:09AM +, Gareth Evans wrote:
> man script says 
> 
> "SEE ALSO
>csh(1) (for the history mechanism)"
> 
> but
> 
> $ man csh
> No manual entry for csh

I'm so glad that we're entering an era where it's normal *not* to have
csh installed and used.  That shell really was a disaster.

Anyway, if you want to read man pages for packages that are not installed
on your system, the World Wide Web is a good source.

Specifically, you could start with
 and see where that takes you.



Re: script/history

2024-02-04 Thread Michael Grant
> $ script foo.txt
> Script started, output log file is 'foo.txt'.
> $ date
> Sun  4 Feb 09:44:00 GMT 2024
> $ exit
> exit
> Script done.
> $ history|tail -n2
> 30797  2024-02-04 09:43:57  script foo.txt
> 30798  2024-02-04 09:44:21  history|tail -n2
> 
> I did try to search on this but just got lots of "bash history" and "history 
> in
> bash script" references.

So this might surprise you but the commands are actually in the
history list!  But not in the current shell.

What happens is this:

You start 'script foo.txt' and this starts a sub bash shell on a
different pseudo tty.  You run some commands, it appends each command
to the history of this sub-shell's history.

You then exit your script.  Those commands you ran are at the bottom
of .bash_history (try to cat that file out after you exit script and
you should see them).

But those commands are not sucked into the history of your current
shell.  Then, you log out (or exit) your current shell and the history
of that shell overwrites the history of the previous one.

If all you want to do is save off the commands after you exit your
script session, then simply move or copy .bash_history out of the way
before it gets overwritten.

You might consider setting $HISTFILE to some other location other than
.bash_history.

Michael Grant


signature.asc
Description: PGP signature


Re: script/history

2024-02-04 Thread hw
On Sun, 2024-02-04 at 09:46 +, Gareth Evans wrote:
> Re the script command, does anyone know of a way to make commands
> run during a script session appear in bash history too?

Maybe this:
https://serverfault.com/questions/16204/how-to-make-bash-scripts-print-out-every-command-before-it-executes

It seems awkward to have scripts being put into the history.  You
could do something like

cat script.sh >> ~/.bash_history

maybe.  How would that be useful?



Re: Script BASH gestion des espaces des noms de fichier

2024-02-02 Thread Pierre Malard
Essaie des cotes dans tes attributions de noms.

Par exemple :
TOTO="${NomFic}"

avec
NomFic="Mon Fichier"

Pareillement cote les appels :
Cmd —variable "${NomFic}"

Par exemple. Le fait de coter l’appel de variable avec des double cote permet à 
BASH de considérer NomFic comme un seul paramètre envoyé à Cmd avec ses blancs. 
Après il faut savoir comment la commande Cmd va traiter tout ça…

> Le 2 févr. 2024 à 07:51, Informatique BILLARD 
>  a écrit :
> 
> Bonjour
> 
> j'ai écrit un petit script qui lance à la fin cette commande :
> 
> pdftk $fichier1 stamp $tampon output $fichier2
> 
> avec $fichier1 et $tampon, $fichier2  sont construit à partir des paramètres 
> fournis au script .
> 
> Mais je rencontre un problème quand il y a un espace dans le nom de fichier 
> ou le répertoire pour pdftk ces espaces engendrent une erreur.
> 
> J'ai pourtant placé l'antislah avant mes espace dans l'affectation des 
> variables.
> 
> tampon=/user/Document/cachet\ pdf
> 
> Merci par avance
> 
> François-Marie
> 

--
Pierre Malard
Responsable architectures système CDS DINAMIS/THEIA Montpellier
IRD - UMR Espace-Dev - UAR CPST - IR Data-Terra
Maison de la Télédétection
500 rue Jean-François Breton
34093 Montpellier Cx 5
France

   « SPAM : Spieced Pork and Meat »
   Pierre Dac (Londres, 1944)
Extrait de « Pierre DAC parle au Français » sur Radio Londres, le 24 mars 1944, 
dans Drôle de guerre, éditions Omnibus (2008), pages 93 à 96. 
(https://www.epi.asso.fr/revue/articles/a1602d.htm)

   |\  _,,,---,,_
   /,`.-'`'-.  ;-;;,_
  |,4-  ) )-,_. ,\ (  `'-'
 '---''(_/--'  `-'\_)   πr

perl -e '$_=q#: 3|\ 5_,3-3,2_: 3/,`.'"'"'`'"'"' 5-.  ;-;;,_:  |,A-  ) )-,_. ,\ 
(  `'"'"'-'"'"': '"'"'-3'"'"'2(_/--'"'"'  `-'"'"'\_): 
24πr::#;y#:#\n#;s#(\D)(\d+)#$1x$2#ge;print'
- --> Ce message n’engage que son auteur <--



signature.asc
Description: Message signed with OpenPGP


Re: Script BASH gestion des espaces des noms de fichier

2024-02-02 Thread Erwann Le Bras

Effectivement François

Merci d'avoir rectifié.

Erwann

Le 02/02/2024 à 13:09, François TOURDE a écrit :

Le 19755ième jour après Epoch,
Erwann Le Bras écrivait:


Éviter les boucles "for" avec listes de fichiers (for f in `ls
"$dir"`) ou (for f in *), les espaces sont mal interprétés.

Ça marche très bien l'utilisation avec for f in *, si tu prends soin
d'utiliser "$f" plutôt que juste $f

Par contre, le "in `ls *`" n'est effectivement pas une bonne idée.


Re: Script BASH gestion des espaces des noms de fichier

2024-02-02 Thread François TOURDE
Le 19755ième jour après Epoch,
Erwann Le Bras écrivait:

> Éviter les boucles "for" avec listes de fichiers (for f in `ls
> "$dir"`) ou (for f in *), les espaces sont mal interprétés.

Ça marche très bien l'utilisation avec for f in *, si tu prends soin
d'utiliser "$f" plutôt que juste $f

Par contre, le "in `ls *`" n'est effectivement pas une bonne idée.



Re: Script BASH gestion des espaces des noms de fichier

2024-02-02 Thread Erwann Le Bras

bonjour

comme dis par ailleurs, pas de problème avec les espaces si les 
variables et chemins sont bien protégés  avec des doubles-cotes (["])


fichier="mon fichier"
dir="$HOME/mon répertoire"
cp "$fichier" "$dir"

Éviter les boucles "for" avec listes de fichiers (for f in `ls "$dir"`) 
ou (for f in *), les espaces sont mal interprétés.

À la place utiliser "find" : find "$dir" -name "${fichier}*" -exec

c'est à peu près tout.

Erwann

Le 02/02/2024 à 08:41, Informatique BILLARD a écrit :


Bonjour

j'ai écrit un petit script qui lance à la fin cette commande :

pdftk $fichier1 stamp $tampon output $fichier2

avec $fichier1 et $tampon, $fichier2  sont construit à partir des 
paramètres fournis au script .


Mais je rencontre un problème quand il y a un espace dans le nom de 
fichier ou le répertoire pour pdftk ces espaces engendrent une erreur.


J'ai pourtant placé l’antislash avant mes espace dans l'affectation 
des variables.


tampon=/user/Document/cachet*\ *pdf

Merci par avance

François-Marie


Re: Script BASH gestion des espaces des noms de fichier

2024-02-02 Thread Informatique BILLARD

merci je ne connaissais pas cet outils

François-Marie

Le 02/02/2024 à 09:54, Klaus Becker a écrit :

Detox est ton ami

Klaus

Re: Script BASH gestion des espaces des noms de fichier

2024-02-02 Thread Informatique BILLARD

Bon

j'ai tourné le problème dans tous les sens et finalement j'ai opté pour 
ceci


1. le nom du fichier passé comme argument au script est traité pour
   remplacer les espaces par des underscore.
2. je fait un renommage de ce fichier avec le nom sans espaces.
3. Puis traitement et tout fonctionne.

Merci à vous.

François-Marie


Le 02/02/2024 à 08:57, Cyrille a écrit :

Bjr,


tampon=/user/Document/cachet\ pdf

et
tampon="/user/Document/cachet\ pdf"
(utiliser des double quote

??

++


Re: Script BASH gestion des espaces des noms de fichier

2024-02-02 Thread Klaus Becker
Detox est ton ami

Klaus


Re: Script BASH gestion des espaces des noms de fichier

2024-02-02 Thread Informatique BILLARD

Le 02/02/2024 à 08:48, Basile Starynkevitch a écrit :


On 2/2/24 08:41, Informatique BILLARD wrote:


Bonjour

j'ai écrit un petit script qui lance à la fin cette commande :

pdftk $fichier1 stamp $tampon output $fichier2

avec $fichier1 et $tampon, $fichier2  sont construit à partir des 
paramètres fournis au script .


Mais je rencontre un problème quand il y a un espace dans le nom de 
fichier ou le répertoire pour pdftk ces espaces engendrent une erreur.


J'ai pourtant placé l’antislash avant mes espace dans l'affectation 
des variables.


tampon=/user/Document/cachet*\ *pdf

Une solution simple c'est de s'interdire les espaces dans les noms de 
fichiers. Pourquoi ne pas coder par exemple
Oui en effet j'ai fini par supprimer les espaces dans les noms de 
fichiers et répertoires. Cependant ce script traite des fichiers 
ayant parfois des espaces et si je dois renommer à chaque fois je 
vais perdre l'intérêt du script.



tampon=/user/Document/cachet.pdf

et ensuite lancer votre script avec /bin/bash -vx lescriptbash


Merci par avance

François-Marie





Re: Script BASH gestion des espaces des noms de fichier

2024-02-02 Thread Cyrille
Bjr,

> tampon=/user/Document/cachet\ pdf
et 
tampon="/user/Document/cachet\ pdf"
(utiliser des double quote

??

++



Re: Script BASH gestion des espaces des noms de fichier

2024-02-01 Thread Jérémy Prego

bonjour,

Le 02/02/2024 à 08:41, Informatique BILLARD a écrit :


Bonjour

j'ai écrit un petit script qui lance à la fin cette commande :

pdftk $fichier1 stamp $tampon output $fichier2



Pour éviter ce problème, on peut mettre les variables entre "

du coup, ça donnerai:

pdftk "$fichier1" stamp "$tampon" output "$fichier2"

avec $fichier1 et $tampon, $fichier2  sont construit à partir des 
paramètres fournis au script .


Mais je rencontre un problème quand il y a un espace dans le nom de 
fichier ou le répertoire pour pdftk ces espaces engendrent une erreur.


J'ai pourtant placé l’antislash avant mes espace dans l'affectation 
des variables.


tampon=/user/Document/cachet*\ *pdf

Merci par avance

François-Marie



Jerem

Re: Script BASH gestion des espaces des noms de fichier

2024-02-01 Thread Basile Starynkevitch



On 2/2/24 08:41, Informatique BILLARD wrote:


Bonjour

j'ai écrit un petit script qui lance à la fin cette commande :

pdftk $fichier1 stamp $tampon output $fichier2

avec $fichier1 et $tampon, $fichier2  sont construit à partir des 
paramètres fournis au script .


Mais je rencontre un problème quand il y a un espace dans le nom de 
fichier ou le répertoire pour pdftk ces espaces engendrent une erreur.


J'ai pourtant placé l’antislash avant mes espace dans l'affectation 
des variables.


tampon=/user/Document/cachet*\ *pdf

Une solution simple c'est de s'interdire les espaces dans les noms de 
fichiers. Pourquoi ne pas coder par exemple


tampon=/user/Document/cachet.pdf

et ensuite lancer votre script avec /bin/bash -vx lescriptbash


Merci par avance

François-Marie


--
Basile Starynkevitch 
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/
See/voir:   https://github.com/RefPerSys/RefPerSys



Re: Script uitvoeren via initramfs

2023-06-01 Thread Paul van der Vlis

Hallo Wouter en anderen,

Op 28-05-2023 om 19:53 schreef Wouter Verhelst:

On Sun, May 28, 2023 at 10:39:45AM +0200, Paul van der Vlis wrote:

Hallo,

Een klant vroeg me iets te doen via initramfs. Ik vertelde hem dat ik daar
weinig verstand van had. En dat ik dat ook wel kon via een chroot.

Toch wou hij graag dat ik eens ging kijken naar initramfs.
En dat blijkt leuk ;-)

Al vrij snel kon ik wat ik wou, maar dat doe ik door de initrd uit te
pakken, het script "init" aan te passen, en de boel weer in te pakken. En
dan rebooten. Dat hacken in "init" lijkt me niet echt de bedoeling.

Ik heb geprobeerd mijn scriptje in /etc/initramfs-tools/conf.d/ te stoppen,
maar het wordt dan uitgevoerd tijdens het maken van de initrd en dat is niet
wat ik wil. Wat ik wil is dat mijn scriptje uitgevoerd wordt na een reboot
voordat het filesystem gemount wordt.

Wie weet een goede manier?


Je moet een script aanmaken in /usr/share/initramfs-tools/hooks dat de
nodige bestanden kopiëert naar de "staging area" die mkinitramfs
aanmaakt.

Een voorbeeld (met uitgebreide commentaar als documentatie) vind je op
https://salsa.debian.org/kernel-team/initramfs-tools/-/blob/master/docs/example_hook


Ik wou in elk geval hartelijk bedanken voor de tips. Ik heb het gelezen 
en er ook wel wat aan gehad. Maar uiteindelijk heb ik het (deze keer) 
toch gedaan op een iets minder nette manier. De initrd is namelijk maar 
voor eenmalig gebruik (een migratie). Normaal draaien de systemen zonder 
initrd.


Het gaat om een hele vloot raspberry Pi's die op afstand moeten worden 
geupgraded van een 32-bit systeem naar een 64-bit systeem.


Ik maak een mapje /new in het systeem, en vervang /boot (met daarin een 
initrd). Dan, tijdens de initrd, vervang ik het root filesystem, zoiets:


mount -t ext4 /dev/mmcblk0p2 /mnt
mv /mnt/* /mnt/old/
mv /mnt/old/new/* /mnt/
umount /mnt

Daarna boot ik door naar het nieuwe systeem en ruim nog wat dingen op, 
zoals die initrd zodat hij niet nogmaals actief wordt.


Werkt heel mooi ;-)

Groet,
Paul


--
Paul van der Vlis Linux systeembeheer Groningen
https://vandervlis.nl/



Re: Script uitvoeren via initramfs

2023-05-31 Thread Diederik de Haas
On Sun May 28, 2023 at 7:53 PM CEST, Wouter Verhelst wrote:
> On Sun, May 28, 2023 at 10:39:45AM +0200, Paul van der Vlis wrote:
> > Een klant vroeg me iets te doen via initramfs.
> > ...
> > Ik heb geprobeerd mijn scriptje in /etc/initramfs-tools/conf.d/ te
> > stoppen, maar het wordt dan uitgevoerd tijdens het maken van de initrd
> > en dat is niet wat ik wil. Wat ik wil is dat mijn scriptje uitgevoerd
> > wordt na een reboot voordat het filesystem gemount wordt.
>
> Je moet een script aanmaken in /usr/share/initramfs-tools/hooks dat de
> nodige bestanden kopiëert naar de "staging area" die mkinitramfs
> aanmaakt.
>
> Een voorbeeld (met uitgebreide commentaar als documentatie) vind je op
> https://salsa.debian.org/kernel-team/initramfs-tools/-/blob/master/docs/
example_hook

Is het niet beter om die scripts in /etc/initramfs-tools/hooks te stoppen ipv 
in /usr/share ?


signature.asc
Description: This is a digitally signed message part.


Re: Script uitvoeren via initramfs

2023-05-28 Thread Wouter Verhelst
On Sun, May 28, 2023 at 10:39:45AM +0200, Paul van der Vlis wrote:
> Hallo,
> 
> Een klant vroeg me iets te doen via initramfs. Ik vertelde hem dat ik daar
> weinig verstand van had. En dat ik dat ook wel kon via een chroot.
> 
> Toch wou hij graag dat ik eens ging kijken naar initramfs.
> En dat blijkt leuk ;-)
> 
> Al vrij snel kon ik wat ik wou, maar dat doe ik door de initrd uit te
> pakken, het script "init" aan te passen, en de boel weer in te pakken. En
> dan rebooten. Dat hacken in "init" lijkt me niet echt de bedoeling.
> 
> Ik heb geprobeerd mijn scriptje in /etc/initramfs-tools/conf.d/ te stoppen,
> maar het wordt dan uitgevoerd tijdens het maken van de initrd en dat is niet
> wat ik wil. Wat ik wil is dat mijn scriptje uitgevoerd wordt na een reboot
> voordat het filesystem gemount wordt.
> 
> Wie weet een goede manier?

Je moet een script aanmaken in /usr/share/initramfs-tools/hooks dat de
nodige bestanden kopiëert naar de "staging area" die mkinitramfs
aanmaakt.

Een voorbeeld (met uitgebreide commentaar als documentatie) vind je op
https://salsa.debian.org/kernel-team/initramfs-tools/-/blob/master/docs/example_hook

-- 
 w@uter.{be,co.za}
wouter@{grep.be,fosdem.org,debian.org}

I will have a Tin-Actinium-Potassium mixture, thanks.



Re: Script uitvoeren via initramfs

2023-05-28 Thread Geert Stappers
On Sun, May 28, 2023 at 10:39:45AM +0200, Paul van der Vlis wrote:
> Hallo,
> 
> Een klant vroeg me iets te doen via initramfs. Ik vertelde hem dat ik daar
> weinig verstand van had. En dat ik dat ook wel kon via een chroot.
> 
> Toch wou hij graag dat ik eens ging kijken naar initramfs.
> En dat blijkt leuk ;-)
> 
> Al vrij snel kon ik wat ik wou, maar dat doe ik door de initrd uit te
> pakken, het script "init" aan te passen, en de boel weer in te pakken.

| $ file /sbin/update-initramfs
| /sbin/update-initramfs: POSIX shell script, ASCII text executable
| $

En  `update-initramfs` heeft een manual page.

> En dan rebooten.

Hopelijk van een VM, of iets anders wat heel erg snel reboot.

} Hacken in "initrd" lijkt me niet echt de bedoeling.

Er is geen noodzaak voor die (zelf)restrictie.
 
> Ik heb geprobeerd mijn scriptje in /etc/initramfs-tools/conf.d/ te stoppen,
> maar het wordt dan uitgevoerd tijdens het maken van de initrd en dat is niet
> wat ik wil. Wat ik wil is dat mijn scriptje uitgevoerd wordt na een reboot
> voordat het filesystem gemount wordt.
> 
> Wie weet een goede manier?

Bootloader zorgt dat `kernel` en `initrd` in geheugen staan
en dat kernel gestart wordt. Kernel weet `initrd` te vinden
en zoekt daarin `init` om die te starten. Het is dan aan `init`
om het script in kwestie te gaan uitvoeren. Nee, het zit niet bij
mijn parate kennis waar dat gebeurd. Als het meezit komt er
vervolginformatie voorbij.


Groeten
Geert Stappers
-- 
Silence is hard to parse



Re: script

2021-07-06 Thread Alejandro
Esto es genial muy agradecido!

Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐

El martes, 6 de julio de 2021 a las 18:37, Parodper  
escribió:

> O 06/07/21 ás 17:38, Alejandro escribiu:
>
> > Hola amigos tengo un archivo MD5SUMS de la web oficial Debian del cual
> >
> > me gustaría sacar el nombre de la 1º distro para convertirlo en una
> >
> > variable que me permita completar una url de forma automática.
> >
> > El problema es que al usar grep y expresiones regulares para obtener el
> >
> > nombre de la distro y versión, que es lo que me interesa, siempre me
> >
> > devuelve también el hash y esto hace que la descarga falle.
> >
> > adjunto archivo y les dejo la expresión regular con la que al menos
> >
> > obtengo la distro que me interesa, me sobra el hash:
> >
> > grep debian-10.-amd64-netinst.iso MD5SUMS*
> >
> > Muchas gracias un saludo a todos!
> >
> > **
> >
> > Sent with ProtonMail https://protonmail.com/ Secure Email.
>
> Añádele la opción -o, grep -o debian-10.*-amd64-netinst.iso MD5SUMS
>
> grep(1):
>
> -o, --only-matching
>
> Print only the matched (non-empty) parts of a matching
>
> line, with each such part on a separate output line.



Re: script

2021-07-06 Thread Parodper

O 06/07/21 ás 17:38, Alejandro escribiu:


Hola amigos tengo un archivo MD5SUMS de la web oficial Debian del cual 
me gustaría sacar el nombre de la 1º distro para convertirlo en una 
variable que me permita completar una url de forma automática.


El problema es que al usar grep y expresiones regulares para obtener el 
nombre de la distro y versión, que es lo que me interesa, siempre me 
devuelve también el hash y esto hace que la descarga falle.


adjunto archivo y les dejo la expresión regular con la que al menos 
obtengo la distro que me interesa, me sobra el hash:


*grep debian-10.*-amd64-netinst.iso MD5SUMS*

*Muchas gracias un saludo a todos!*
**
Sent with ProtonMail  Secure Email.



Añádele la opción -o, grep -o debian-10.*-amd64-netinst.iso MD5SUMS
grep(1):
-o, --only-matching
  Print  only  the  matched  (non-empty) parts of a matching
  line, with each such part on a separate output line.



Re: script

2021-07-06 Thread Camaleón
El 2021-07-06 a las 15:38 +, Alejandro escribió:

> Hola amigos tengo un archivo MD5SUMS de la web oficial Debian del cual me 
> gustaría sacar el nombre de la 1º distro para convertirlo en una variable que 
> me permita completar una url de forma automática.
> 
> El problema es que al usar grep y expresiones regulares para obtener el 
> nombre de la distro y versión, que es lo que me interesa, siempre me devuelve 
> también el hash y esto hace que la descarga falle.
> 
> adjunto archivo y les dejo la expresión regular con la que al menos obtengo 
> la distro que me interesa, me sobra el hash:
> 
> grep debian-10.*-amd64-netinst.iso MD5SUMS
> 
> Muchas gracias un saludo a todos!

Algo rápido y sencillo que podrás depurar:

sm01@stt008:~$ head -1 md5sums.txt | awk '{print $2}'
debian-10.10.0-amd64-netinst.iso

Saludos,

-- 
Camaleón 



Re: Script ffmpeg ?

2020-12-26 Thread ptilou
Slt,

On m'a dit vlc, ffmppeg c'est de la merde, pourquoi ?
Sinon j'essaye d'installer NVIDIA via Modprobe, le man et le help, disent a, la 
commande dit not found, c'est toi qui t'ennuit ??
La prochaine fois enleve le de la doc !

Le mercredi 23 décembre 2020 à 09:40:03 UTC+1, Marc Chantreux a écrit :
> On Tue, Dec 22, 2020 at 08:44:48PM -0800, ptilou wrote: 
> > Me semble une solution mieux fonctionner ? Bien que je ne comprend pas le 
> > -IX , après -n1 
> > Du coup je rame 
> tu sais: 
> 
> * tu as droit de lire le man: c'est super instructif 
> * tu peux jouer avec des petits exemples. en voilà 
> 
> seq 20 | xargs -n5 
> 
> 1 2 3 4 5 
> 6 7 8 9 10 
> 11 12 13 14 15 
> 16 17 18 19 20 
> 
> seq 20 | xargs -n10 
> 
> 1 2 3 4 5 6 7 8 9 10 
> 11 12 13 14 15 16 17 18 19 20 
> 
> seq 5 | xargs -IX echo cette fois ca faut X 
> 
> cette fois ca faut 1 
> cette fois ca faut 2 
> cette fois ca faut 3 
> cette fois ca faut 4 
> cette fois ca faut 5 
> 
> seq 5 | xargs -IY echo cette fois ca faut Y 
> 
> cette fois ca faut 1 
> cette fois ca faut 2 
> cette fois ca faut 3 
> cette fois ca faut 4 
> cette fois ca faut 5 
> 
> apres si tu tiens absolument a tapper sur de mauvaises pratiques:
> function f_image-fusion { 
> convert "$1" -resize 40% -colorspace Gray "${1%}gray.jpg" 
> }
> find ton truc | while read -r i; do 
> f_image_fusion "$i" 
> done; 
> 
> marc

-- 
ptilou



Re: Script ffmpeg ?

2020-12-23 Thread ptilou
Slt,


Le mercredi 23 décembre 2020 à 09:40:03 UTC+1, Marc Chantreux a écrit :
> On Tue, Dec 22, 2020 at 08:44:48PM -0800, ptilou wrote: 
> > Me semble une solution mieux fonctionner ? Bien que je ne comprend pas le 
> > -IX , après -n1 
> > Du coup je rame 
> tu sais: 
> 
> * tu as droit de lire le man: c'est super instructif 
> * tu peux jouer avec des petits exemples. en voilà 
> 
Pas trop je suis étudiants et là fais une semaine que j’ai pas bossé, elle est 
pas encore bloqué ( la cb)

Ma question est pourquoi la ligne fonctionne en direct dans le batsh, et pas 
avec le script alors qu’une autre fonctionne (convert) ?

Une fois que tu me dis ça j’avance réellement , le pourquoi c’est une mauvaise 
solution vient après 
 
> seq 20 | xargs -n5 
> 
> 1 2 3 4 5 
> 6 7 8 9 10 
> 11 12 13 14 15 
> 16 17 18 19 20 
> 
> seq 20 | xargs -n10 
> 
> 1 2 3 4 5 6 7 8 9 10 
> 11 12 13 14 15 16 17 18 19 20 
> 
> seq 5 | xargs -IX echo cette fois ca faut X 
> 
> cette fois ca faut 1 
> cette fois ca faut 2 
> cette fois ca faut 3 
> cette fois ca faut 4 
> cette fois ca faut 5 
> 
> seq 5 | xargs -IY echo cette fois ca faut Y 
> 
> cette fois ca faut 1 
> cette fois ca faut 2 
> cette fois ca faut 3 
> cette fois ca faut 4 
> cette fois ca faut 5 
> 
> apres si tu tiens absolument a tapper sur de mauvaises pratiques:
> function f_image-fusion { 
> convert "$1" -resize 40% -colorspace Gray "${1%}gray.jpg" 
> }
> find ton truc | while read -r i; do 
> f_image_fusion "$i" 
> done; 
> 

Je suppose que tu veux justifier soit les cours que tu donne soit ceux que tu a 
pris, si je copie cela ne fonctionne pas or je te demande comment imbriquer, je 
t’ais dit que j’ai essayé entre autre &&, et donc pourquoi ?

Y a aussi un autre truc pourquoi constamment même quand je discute d’autre 
domaine y a une ou deux personne qui me répondent ?
Donc j’avais dit à un Parinuxiens’ que ça sert à rien d’administrer ses propres 
DNS, a un Windosiens qui cherche des clés usb étanches pour se doucher avec, et 
j’ai remarqué que la susceptibilité se hisse au sommet des priorités de la 
science, donc comment on vérifie les DNS, puisque ils sont redirigé 
automatiquement par le soft de la box ?
Après c’est aimable de me répondre, j’attend d’avancer, et donc quand quelqu’un 
me pose une question j’évite de le renvoyer a des considération génétique un 
genre de calotins ...

Ah je me suis rendu compte quún imbecile vient me changer mes support optique 
et mes ses désobligeance numerique, tiens j’ai peut-être trouvé une solution a 
la BNF, les magazines avec dvd, sont consultables !
(C’est le partage de mon savoir, bon il est réservé au débutant, il me semble 
quíl y a un dvd avec 7000 script cést anglais, mais comme c’est Gpl, pourquoi 
c’est pas partagé ?)

Y a aussi une dernière chose quand tu me dis me dis faut pratiquer, c’est vous 
au CNIT, qui m’avait dit c’est mieux Debian on va d’aider, je ne peux pas 
participer parce que tu ne m’aide pas, et pour un script, dit moi ou tu veux en 
venir ?

— 
Ptilou



Re: Script ffmpeg ?

2020-12-23 Thread Marc Chantreux
On Tue, Dec 22, 2020 at 08:44:48PM -0800, ptilou wrote:
> Me semble une solution mieux fonctionner ? Bien que je ne comprend pas le -IX 
> , après -n1
> Du coup je rame 

tu sais:

* tu as droit de lire le man: c'est super instructif
* tu peux jouer avec des petits exemples. en voilà

seq 20 | xargs -n5

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20

seq 20 | xargs -n10

1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20

seq 5 | xargs -IX echo cette fois ca faut X

cette fois ca faut 1
cette fois ca faut 2
cette fois ca faut 3
cette fois ca faut 4
cette fois ca faut 5

seq 5 | xargs -IY echo cette fois ca faut Y

cette fois ca faut 1
cette fois ca faut 2
cette fois ca faut 3
cette fois ca faut 4
cette fois ca faut 5

apres si tu tiens absolument a tapper sur de mauvaises pratiques:

function f_image-fusion {
convert "$1" -resize 40% -colorspace Gray "${1%}gray.jpg"
}

find ton truc | while read -r i; do
f_image_fusion "$i"
done;

marc



Re: Script ffmpeg ?

2020-12-22 Thread ptilou
Le mardi 22 décembre 2020 à 20:10:02 UTC+1, Marc Chantreux a écrit :
> hello, 
> 
> regarde du coté d'xargs, vraiment :) 
> 
> tu devrais pouvoir écrire ton truc de la manière suivante: 
> 
> f_image_extract () xargs -0 -P4 -n1 -IX \ 
> ffmpeg -i X -r 6 -f image2 -qscale 1 photo-%0d.jpg 
> 
> find ./ -iname \*.mov | f_image_extract 
> 
> le bonus c'est que -P4 traite 4 videos simultanément (c'est l'hiver: on 
> se chauffe comme on peut) 
> 

find ./ -iname \*.mov | xargs -0 -P4 -n1 -IX ffmpeg -i X -r 6 -f image2 -qscale 
1 photo-%0d.jpg
Me semble une solution mieux fonctionner ? Bien que je ne comprend pas le -IX , 
après -n1
Du coup je rame 

Alors la ligne comme cela fonctionne, mais pas dans le script, pour quelle 
raison, histoire que j’avance. ...

Ah et le script fonctionne 
#!/bin/bash

function f_image-fusion {
convert "$1" -resize 40% -colorspace Gray "${1%}gray.jpg"
}

{
find ./ -iname \*.jpg
echo "EOF"
} | {
while true; do
read -r i;
test "$i" = "EOF" && break;
f_image-fusion "$i";
done
}

Et donc pourquoi pour la fonction le script fonctionne et pourquoi pour ffmpeg 
non, alors que la ligne seul dans le même batch fonctionne ?

Si je remplace convert comme ci-dessus par mkdir il crée un dosssier, et donc 
comment imbriquer plusieurs commande batch , j’avais essayé de les mettre à la 
suite par plusieur opérateur sous Ubuntu 16.04 soit cela se plante, soit cela 
n’excuse que la première commande , comme première idée est erronée et. Que 
l’hiver les veux se chauffe comme il peut dit moi dans quel livre chercher ?

Merci

— 
Ptilou



Re: Script ffmpeg ?

2020-12-22 Thread Marc Chantreux
hello,

regarde du coté d'xargs, vraiment :)

tu devrais pouvoir écrire ton truc de la manière suivante:

f_image_extract () xargs -0 -P4 -n1 -IX \
ffmpeg -i X -r 6 -f image2 -qscale 1 photo-%0d.jpg

find ./ -iname \*.mov | f_image_extract

le bonus c'est que -P4 traite 4 videos simultanément (c'est l'hiver: on
se chauffe comme on peut)

marc



Re: Script does not do what it is told to do

2019-10-27 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-26 9:55 p.m., The Wanderer wrote:
> On 2019-10-26 at 21:33, Ken Heard wrote:
> 
>> The tar scripts now look like this. 
>> --- 
>> #!/bin/bash # Script to back up all browser files in directory
>> /home/ken/mozilla. echo here tar -cpzf
>> /media/fde/backups/kbrowsers.tgz  --exclude-caches --wildcards -T
>> docs/tarlists/kbrowsers.lst 
>> --- This one
>> exceptionally has 'echo here" above the tar command at the 
>> suggestion of Kushal Kumeran.
> 
> Where is this script located (full path and filename)?
> 
> If I'm reading things right, you also might want to either put the
> 'cd /home/ken' line back (no need for the other cd), or use the
> full path to kbrowsers.lst instead of a relative path; otherwise
> this won't work right if you run it from any directory which
> doesn't have that relative path under it.
> 
> (If kbrowsers.lst has relative paths in it, this might not work 
> correctly from another location without the cd anyway, even if you
> do use a full path on the command line. I don't have experience
> with that tar feature myself.)
> 
>> Also at his request I ran the following two commands: 'which
>> tarkbrowsers' which returned '/home/ken/bin/tarkbrowsers', and 
>> 'cat $(which tarkbrowsers)' which returned 
>> --- # Script
>> to back up all browser files in directory /home/ken/mozilla. 
>> CURPWD=$PWD cd /home/ken tar -czf
>> /media/ssda/backups/kbrowsers.tgz  --exclude-caches --wildcards
>> -T docs/tarlists/kbrowsers.lst cd $CURPWD 
>> --- As this
>> return includes the change of directories commands it is clear 
>> that somewhere there is a series of extraneous scripts but the 
>> software is being coy about telling me where they are.
> 
> Eh? No, it isn't. It already told you clearly that this latter
> script is '/home/ken/bin/tarkbrowsers'.
> 
> Your mail doesn't (seem to?) give us enough information for us to 
> identify where the former of the two given scripts is, but
> presumably you know where to find that one, since you were able to
> give its contents here.
> 
> If you don't want to run this latter version of the script, either
> move it out of its current directory (which is apparently in your
> PATH), or replace it with the version you do want to run.
> 
> 
> (I'm presuming that the newline between '--exclude-caches' and 
> '--wildcards' in each script is an artifact of the mail process,
> and not present in the actual on-disk script. If it *is* present
> there, then these are both going to break and not do what you
> expect.)
> 
Thank you for your prompt response.  I understand what you mean about
full and relevant paths.  I will have to look into this issue; it may
affect the outcome of the script regardless of the computer as both
the Toronto and Thailand computers are set up the same way, with the
same paths, etc.

Regards, Ken

-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXbWk7AAKCRCU2UnM6QmZ
N/WlAJ4+Nso8uo4X/wLXmj5TMvqSO0uMggCdEphMTf/xIiDxtAJbnQyUV/l/8vA=
=7+2G
-END PGP SIGNATURE-



Re: Script does not do what it is told to do

2019-10-26 Thread The Wanderer
On 2019-10-26 at 21:33, Ken Heard wrote:

> The tar scripts now look like this.
> ---
> #!/bin/bash
> # Script to back up all browser files in directory /home/ken/mozilla.
> echo here
> tar -cpzf /media/fde/backups/kbrowsers.tgz  --exclude-caches
> --wildcards -T docs/tarlists/kbrowsers.lst
> ---
> This one exceptionally has 'echo here" above the tar command at the
> suggestion of Kushal Kumeran.

Where is this script located (full path and filename)?

If I'm reading things right, you also might want to either put the 'cd
/home/ken' line back (no need for the other cd), or use the full path to
kbrowsers.lst instead of a relative path; otherwise this won't work
right if you run it from any directory which doesn't have that relative
path under it.

(If kbrowsers.lst has relative paths in it, this might not work
correctly from another location without the cd anyway, even if you do
use a full path on the command line. I don't have experience with that
tar feature myself.)

> Also at his request I ran the following two commands:
> 'which tarkbrowsers' which returned '/home/ken/bin/tarkbrowsers', and
> 'cat $(which tarkbrowsers)' which returned
> ---
> # Script to back up all browser files in directory /home/ken/mozilla.
> CURPWD=$PWD
> cd /home/ken
> tar -czf /media/ssda/backups/kbrowsers.tgz  --exclude-caches
> --wildcards -T docs/tarlists/kbrowsers.lst
> cd $CURPWD
> ---
> As this return includes the change of directories commands it is clear
> that somewhere there is a series of extraneous scripts but the
> software is being coy about telling me where they are.

Eh? No, it isn't. It already told you clearly that this latter script is
'/home/ken/bin/tarkbrowsers'.

Your mail doesn't (seem to?) give us enough information for us to
identify where the former of the two given scripts is, but presumably
you know where to find that one, since you were able to give its
contents here.

If you don't want to run this latter version of the script, either move
it out of its current directory (which is apparently in your PATH), or
replace it with the version you do want to run.


(I'm presuming that the newline between '--exclude-caches' and
'--wildcards' in each script is an artifact of the mail process, and not
present in the actual on-disk script. If it *is* present there, then
these are both going to break and not do what you expect.)

-- 
   The Wanderer may regret sending this, if recent history is any guide

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw



signature.asc
Description: OpenPGP digital signature


Re: Script does not do what it is told to do

2019-10-26 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I want at this time to thank all of you for taking the time to provide
various suggestions as to how to fix the problems I describe in my
original post and in my previous thread 'Signs of hard drive failure?'
My reason for the thank you is that early Monday morning 28 October I
am leaving for Thailand and will not be back in Toronto until
mid-April 2020 and so will not have time for any follow up before I
leave.

Consequently when my Toronto computer is closed tomorrow it will not
be opened or used for the next six months approximately. For those six
months I will be using my desktop computer in Thailand which will have
been idle from April 2019 to November 2019. I will however summarize
here what I have found out so far in Toronto.

With regard to possible hard disk failures, with the help of some of
you I found out that the internal two hard drives have some life left
in them.  What had failed however some of my backup portable devices,
a 1 tb portable USB hard drive and two of my six high capacity (32-64
tb) USB flash drives, all of which I use for back-ups.  What I think
had not failed was a SanDisk Extreme 500 (500 gb so they say, but
somewhat less) solid state USB portable drive.

So for my working files which I will be taking with me I am using one
of the 'good' 64 tb USB flash drives mount on /media/fde, and maybe
the the SanDisk on /media/ssda. My working files will be compressed
into some twenty tarballs written to the fde drive, but not on the
ssda for reasons explained below. I am also storing those tarballs in
Dropbox.

The scripts for these two devices follow.  Both are encrypted.
- --
#!/bin/bash
# Script to open and mount fde

sudo cryptsetup luksOpen UUID=26bb9cea-4ac0-47fa-838b-067baeb1936f fde
mount /media/fde
- --
#!/bin/bash
# Script to open and mount ssda

sudo cryptsetup luksOpen UUID=347eec80-ede8-4b10-bef6-24065ced3e97
ssda mount /media/ssda
- ---
As I had found that all these scripts could operate without changing
the working directory back and forth from /home/ken I removed from
them all the lines changing the working directories which shocked,
horrified and amazed many of you.

The first script above works; it can open the fde drive.  The second
one does not work, but it will work if the tar command is extracted
from the script and run independently in a virtual terminal.  (By the
way I have sudo set up to allow me to open every file without
password, as this is the only computer on the premises.)

The tar scripts now look like this.
- ---
#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
echo here
tar -cpzf /media/fde/backups/kbrowsers.tgz  --exclude-caches
- --wildcards -T docs/tarlists/kbrowsers.lst
- ---
This one exceptionally has 'echo here" above the tar command at the
suggestion of Kushal Kumeran.  Also at his request I ran the following
two commands:
'which tarkbrowsers' which returned '/home/ken/bin/tarkbrowsers', and
'cat $(which tarkbrowsers)' which returned
- ---
# Script to back up all browser files in directory /home/ken/mozilla.
CURPWD=$PWD
cd /home/ken
tar -czf /media/ssda/backups/kbrowsers.tgz  --exclude-caches
- --wildcards -T docs/tarlists/kbrowsers.lst
cd $CURPWD
- ---
As this return includes the change of directories commands it is clear
that somewhere there is a series of extraneous scripts but the
software is being coy about telling me where they are.  As about a
fortnight ago all these scripts worked as they should have, it may be
possible that the ones which do not work now are those which I did not
change in the meantime.

So here is where the matter stands now.  I will be using these scripts
in Thailand and determine whether these idiosyncrasies occur there,
where I will have a buster machine instead of the stretch one I am
still using in Toronto.  So I may be on the thread again in Thailand,
and or possibly again in Toronto in April 2020.

Regards, Ken Heard







-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXbTz8gAKCRCU2UnM6QmZ
N1ZGAJ9oiCkQsjTrdBa3HC5p5+CqybdO4ACeIex9comH1W7x1H3mbt7N1Tdm0pI=
=VKWL
-END PGP SIGNATURE-



Re: Script does not do what it is told to do

2019-10-26 Thread Kushal Kumaran
Ken Heard  writes:

> Whenever I run this script -- or several others like it
>
> #!/bin/bash
> # Script to back up all browser files in directory /home/ken/mozilla.
> STARTDIR=$PWD
> cd /home/ken
> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> --wildcards -T docs/tarlists/kbrowsers.lst
> cd "$STARTDIR"
>
> it returns the following:
>
> ken@Turing:~$ tarkbrowsers
> tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
> file or directory
> tar (child): Error is not recoverable: exiting now
> tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
> tar: Child returned status 2
> tar: Error is not recoverable: exiting now
>
> It is trying to save the tarball to a different portable storage
> device, ssda, which had failed and consequently is no longer in
> /etc/fstab.  How could such a thing happen?
>

Please check the output of these commands:

which tarkbrowsers
cat $(which tarkbrowsers)

I suspect your invocation is not running the version of the script you
expect.

> However, if I pull the line with the tar command out of the script and
> running it independently it does what it is told.  If there is
> something wrong with the script I can't find it.
>
> I also tried the script with the second line reading STARTDIR="$PWD";
> but that change made no difference, the result was the same.
>

Try adding an "echo here" line at the beginning of the script and seeing
if that shows up.  If not, then you know for certain you are not running
what you think you are.

-- 
regards,
kushal



Re: Script does not do what it is told to do

2019-10-25 Thread Michael Howard

On 25/10/2019 16:37, David Wright wrote:

On Fri 25 Oct 2019 at 14:28:02 (+0100), Michael Howard wrote:

On 25/10/2019 14:11, Greg Wooledge wrote:

On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:

On 24/10/2019 23:37, Ken Heard wrote:

#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
STARTDIR=$PWD
cd /home/ken
tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
- --wildcards -T docs/tarlists/kbrowsers.lst
cd "$STARTDIR"

There is nothing inherently wrong with the script,

Untrue.  I pointed out the flaws last time this subject was discussed
on this mailing list.  Was that just a few days ago, or was it last
week?  I don't remember.

Sorry, but it _is_ true. One can't know, nor should one, if the
variables and paths are correct, but if they are, i.e. all things
being equal, the script  is inherrently correct. Of course, it
certainly isn't optimal.

What's the role of the hyphen between the two --switches, please.


in that it would work if
all other things were equal, but they are clearly not.

Lots of scripts will work "if certain conditions hold true".

See above.

If one "shouldn't know" about such conditions, then it seems pointless
to post this sort of problem on the list. One is better employed in
checking one's own assumptions, as Thomas has shown elsewhere in the
thread.


That's the
fundamental problem here.  The script shown here is incredibly fragile,
and the author did not correct the flaws that I already pointed out
last time.  It may "work" under certain conditions.  How likely those
conditions are to be true, I have no way to know.

I have no idea about when or where the OP may have posted previously.

Four days ago, on this list. Looking back to check the date, I see
that the said hyphen had a different, but equally mysterious, role
in the OP's script back there. Perhaps you could explain that hyphen
at the same time.

https://lists.debian.org/debian-user/2019/10/msg00758.html


Using the -C option to tar is preferable to the way you are doing it.

Yup, that was one of the three(?) proposals I made last time around,
none of which were followed.  *shrug*  Not much more I can do when
nobody listens to me.

With your attitude, little wonder nobody listens to you. You're
probably on the ignore list :)

That might explain some of the scripts seen here. I find Greg's
comments on scripts very valuable, and they often remind me to
check out the pages at http://mywiki.wooledge.org/BashGuide.
It would be exaggerating to say that I wait with bated breath for
Greg's comments whenever I post a script here myself.

Greg's criticism's are far more useful than some of the immaterial
English corrections I've seen here.

Cheers,
David.


Well good for you. Nice to see Greg as a bodyguard.

plonk!

In case you don't know and to save you the time replying, that was the 
sound of you hitting the kill file.


Mike.

--




Re: Script does not do what it is told to do

2019-10-25 Thread David Wright
On Fri 25 Oct 2019 at 11:49:46 (-0400), The Wanderer wrote:
> On 2019-10-25 at 11:37, David Wright wrote:
> > On Fri 25 Oct 2019 at 14:28:02 (+0100), Michael Howard wrote:
> >> On 25/10/2019 14:11, Greg Wooledge wrote:
> 
> >>> Untrue.  I pointed out the flaws last time this subject was
> >>> discussed on this mailing list.  Was that just a few days ago, or
> >>> was it last week?  I don't remember.
> >> 
> >> Sorry, but it _is_ true. One can't know, nor should one, if the 
> >> variables and paths are correct, but if they are, i.e. all things 
> >> being equal, the script  is inherrently correct. Of course, it 
> >> certainly isn't optimal.
> > 
> > What's the role of the hyphen between the two --switches, please.
> 
> I'm not sure whether it can meaningfully serve this function in the
> specific case given, but generally - particularly, IIRC, for GNU
> programs - a standalone '-' means something like "treat the data you
> receive from stdin as if it were the contents of an input file".
> 
> That wouldn't seem to fit too well with the use of the '-T' option,
> which appears to mean "read the list of input filenames from the
> specified file", but it's what I'd normally expect that syntax to mean.

Sure. - can indicate either of stdin or stdout when it follows -f,
stdin after -T, and so on. But I'm asking about its role in this
"correct script", and the earlier one where it doesn't even stand
alone. (There's no sign of redirection in either script.)

Cheers,
David.



Re: Script does not do what it is told to do

2019-10-25 Thread The Wanderer
On 2019-10-25 at 11:37, David Wright wrote:

> On Fri 25 Oct 2019 at 14:28:02 (+0100), Michael Howard wrote:
> 
>> On 25/10/2019 14:11, Greg Wooledge wrote:

>>> Untrue.  I pointed out the flaws last time this subject was
>>> discussed on this mailing list.  Was that just a few days ago, or
>>> was it last week?  I don't remember.
>> 
>> Sorry, but it _is_ true. One can't know, nor should one, if the 
>> variables and paths are correct, but if they are, i.e. all things 
>> being equal, the script  is inherrently correct. Of course, it 
>> certainly isn't optimal.
> 
> What's the role of the hyphen between the two --switches, please.

I'm not sure whether it can meaningfully serve this function in the
specific case given, but generally - particularly, IIRC, for GNU
programs - a standalone '-' means something like "treat the data you
receive from stdin as if it were the contents of an input file".

That wouldn't seem to fit too well with the use of the '-T' option,
which appears to mean "read the list of input filenames from the
specified file", but it's what I'd normally expect that syntax to mean.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw



signature.asc
Description: OpenPGP digital signature


Re: Script does not do what it is told to do

2019-10-25 Thread David Wright
On Fri 25 Oct 2019 at 14:28:02 (+0100), Michael Howard wrote:
> On 25/10/2019 14:11, Greg Wooledge wrote:
> > On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:
> > > On 24/10/2019 23:37, Ken Heard wrote:
> > > > #!/bin/bash
> > > > # Script to back up all browser files in directory /home/ken/mozilla.
> > > > STARTDIR=$PWD
> > > > cd /home/ken
> > > > tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> > > > - --wildcards -T docs/tarlists/kbrowsers.lst
> > > > cd "$STARTDIR"
> > > There is nothing inherently wrong with the script,
> > Untrue.  I pointed out the flaws last time this subject was discussed
> > on this mailing list.  Was that just a few days ago, or was it last
> > week?  I don't remember.
> 
> Sorry, but it _is_ true. One can't know, nor should one, if the
> variables and paths are correct, but if they are, i.e. all things
> being equal, the script  is inherrently correct. Of course, it
> certainly isn't optimal.

What's the role of the hyphen between the two --switches, please.

> > > in that it would work if
> > > all other things were equal, but they are clearly not.
> > Lots of scripts will work "if certain conditions hold true".
> 
> See above.

If one "shouldn't know" about such conditions, then it seems pointless
to post this sort of problem on the list. One is better employed in
checking one's own assumptions, as Thomas has shown elsewhere in the
thread.

> > That's the
> > fundamental problem here.  The script shown here is incredibly fragile,
> > and the author did not correct the flaws that I already pointed out
> > last time.  It may "work" under certain conditions.  How likely those
> > conditions are to be true, I have no way to know.
> 
> I have no idea about when or where the OP may have posted previously.

Four days ago, on this list. Looking back to check the date, I see
that the said hyphen had a different, but equally mysterious, role
in the OP's script back there. Perhaps you could explain that hyphen
at the same time.

https://lists.debian.org/debian-user/2019/10/msg00758.html

> > > Using the -C option to tar is preferable to the way you are doing it.
> > Yup, that was one of the three(?) proposals I made last time around,
> > none of which were followed.  *shrug*  Not much more I can do when
> > nobody listens to me.
> 
> With your attitude, little wonder nobody listens to you. You're
> probably on the ignore list :)

That might explain some of the scripts seen here. I find Greg's
comments on scripts very valuable, and they often remind me to
check out the pages at http://mywiki.wooledge.org/BashGuide.
It would be exaggerating to say that I wait with bated breath for
Greg's comments whenever I post a script here myself.

Greg's criticism's are far more useful than some of the immaterial
English corrections I've seen here.

Cheers,
David.



Re: Script does not do what it is told to do

2019-10-25 Thread David Wright
On Fri 25 Oct 2019 at 03:45:45 (+0200), deloptes wrote:
> Ken Heard wrote:
> 
> > -BEGIN PGP SIGNED MESSAGE-
> > Hash: SHA1
> > 
> > On 2019-10-24 7:12 p.m., Anuradha Weeraman wrote:
> > 
> >> On Thu, Oct 24, 2019 at 06:37:08PM -0400, Ken Heard wrote:
> >>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \ -
> >>> --wildcards -T docs/tarlists/kbrowsers.lst
> >> 
> >> Try removing the single '-' at the beginning of the second line...
> > 
> > In this instance it does not matter whether that '-' is there or not.
> >  Pulling that line out of the script and running it independently
> > works both with and without it.
> > 
> 
> 
> In the original post I did not see any dash screenshot attached

- And would you blame that on Knode or gmane (I use neither)?

It's also noticeable that the said hyphen, which was at the beginning
of the line in the OP and was quoted as such in the first reply, had
migrated to the end of the line in the OP's reply. That's not
exactly helpful when discussing anything to do with tar, notorious
for problems caused by its commandline syntax.

Does any of the odd punctuation \
- in this post - get affected similarly when
lines are kept short?

Re the OP, there's a lot of information we aren't a party to;
for example, what are /media/fde and /media/ssda - we've only
been told what one of them isn't. It also wouldn't be difficult
to put set -x into the script, which would show what's being
executed as well as confirming that the correct script is
being run (because there are "several others like it") by
tarkbrowsers.

Cheers,
David.



Re: Script does not do what it is told to do

2019-10-25 Thread Thomas Schmitt
Hi,

Ken Heard wrote:
> Whenever I run this script -- or several others like it
> [...]
> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> - --wildcards -T docs/tarlists/kbrowsers.lst
> [...]
> it returns the following:
> [...]
> tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
> file or directory
> tar (child): Error is not recoverable: exiting now
> tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
> [...]
> However, if I pull the line with the tar command out of the script and
> running it independently it does what it is told.  If there is
> something wrong with the script I can't find it.

The only plausible theories i read so far are:
A: The script you run is not the script from which you take the tar
   command line.
B: tar gets somehow convinced that /media/fde/backups/kbrowsers.tgz
   is actually meant as /media/ssda/backups/kbrowsers.tgz.

(This is independent of the flaws of the script, which where pointed out.)

So i would try to exclude cause A by adding message output to the script,
and cause B by looking at the components of the .tgz path.
I.e. i would insert

  echo "Yes. This is indeed the script."
  ls -ld /media
  ls -ld /media/fde
  ls -ld /media/fde/backups
  ls -ld /media/fde/backups/kbrowsers.tgz

before

  tar -czf /media/fde/backups/kbrowsers.tgz   --exclude-caches \

Then i'd run the script and be curious what happens.


Have a nice day :)

Thomas



Re: Script does not do what it is told to do

2019-10-25 Thread Greg Wooledge
On Fri, Oct 25, 2019 at 02:28:02PM +0100, Michael Howard wrote:
> On 25/10/2019 14:11, Greg Wooledge wrote:
> > On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:
> > > On 24/10/2019 23:37, Ken Heard wrote:
> > > > #!/bin/bash
> > > > # Script to back up all browser files in directory /home/ken/mozilla.
> > > > STARTDIR=$PWD
> > > > cd /home/ken
> > > > tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> > > > - --wildcards -T docs/tarlists/kbrowsers.lst
> > > > cd "$STARTDIR"
> > > There is nothing inherently wrong with the script,
> > Untrue.  I pointed out the flaws last time this subject was discussed
> > on this mailing list.  Was that just a few days ago, or was it last
> > week?  I don't remember.
> 
> Sorry, but it _is_ true. One can't know, nor should one, if the variables
> and paths are correct, but if they are, i.e. all things being equal, the
> script  is inherrently correct. Of course, it certainly isn't optimal.

https://lists.debian.org/debian-user/2019/10/msg00768.html



Re: Script does not do what it is told to do

2019-10-25 Thread Michael Howard

On 25/10/2019 14:11, Greg Wooledge wrote:

On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:

On 24/10/2019 23:37, Ken Heard wrote:

#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
STARTDIR=$PWD
cd /home/ken
tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
- --wildcards -T docs/tarlists/kbrowsers.lst
cd "$STARTDIR"

There is nothing inherently wrong with the script,

Untrue.  I pointed out the flaws last time this subject was discussed
on this mailing list.  Was that just a few days ago, or was it last
week?  I don't remember.



Sorry, but it _is_ true. One can't know, nor should one, if the 
variables and paths are correct, but if they are, i.e. all things being 
equal, the script  is inherrently correct. Of course, it certainly isn't 
optimal.




in that it would work if
all other things were equal, but they are clearly not.

Lots of scripts will work "if certain conditions hold true".



See above.



That's the
fundamental problem here.  The script shown here is incredibly fragile,
and the author did not correct the flaws that I already pointed out
last time.  It may "work" under certain conditions.  How likely those
conditions are to be true, I have no way to know.



I have no idea about when or where the OP may have posted previously.



Using the -C option to tar is preferable to the way you are doing it.

Yup, that was one of the three(?) proposals I made last time around,
none of which were followed.  *shrug*  Not much more I can do when
nobody listens to me.



With your attitude, little wonder nobody listens to you. You're probably 
on the ignore list :)


Mike.

--




Re: Script does not do what it is told to do

2019-10-25 Thread Greg Wooledge
On Fri, Oct 25, 2019 at 08:33:09AM +0100, Michael Howard wrote:
> On 24/10/2019 23:37, Ken Heard wrote:
> > #!/bin/bash
> > # Script to back up all browser files in directory /home/ken/mozilla.
> > STARTDIR=$PWD
> > cd /home/ken
> > tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> > - --wildcards -T docs/tarlists/kbrowsers.lst
> > cd "$STARTDIR"

> There is nothing inherently wrong with the script,

Untrue.  I pointed out the flaws last time this subject was discussed
on this mailing list.  Was that just a few days ago, or was it last
week?  I don't remember.

> in that it would work if
> all other things were equal, but they are clearly not.

Lots of scripts will work "if certain conditions hold true".  That's the
fundamental problem here.  The script shown here is incredibly fragile,
and the author did not correct the flaws that I already pointed out
last time.  It may "work" under certain conditions.  How likely those
conditions are to be true, I have no way to know.

> Using the -C option to tar is preferable to the way you are doing it.

Yup, that was one of the three(?) proposals I made last time around,
none of which were followed.  *shrug*  Not much more I can do when
nobody listens to me.



Re: Script does not do what it is told to do

2019-10-25 Thread tomas
On Fri, Oct 25, 2019 at 09:33:51AM +0200, john doe wrote:
> On 10/25/2019 9:16 AM, to...@tuxteam.de wrote:
> > On Fri, Oct 25, 2019 at 02:40:00AM +0200, deloptes wrote:
> >> Ken Heard wrote:
> >>
> >>> Whenever I run this script -- or several others like it
> >>>
> >>> #!/bin/bash
> >>> # Script to back up all browser files in directory /home/ken/mozilla.
> >>> STARTDIR=$PWD
> >>> cd /home/ken
> >>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> >>> --wildcards -T docs/tarlists/kbrowsers.lst
> >>> cd "$STARTDIR"
> >>>
> >>> it returns the following:
> >>>
> >>
> >> this is not possible because in the script you tell tar to create archive
> >> in /media/fde/backups/
> >
> > Possibly /media/fde is a (broken) symbolic link to /media/ssda?
> >
> > Besides (but this probably hasn't to do with your failure):
> > what are you trying to achieve with 'STARTDIR=$PWD' and then
> > 'cd "$STARTDIR"'?
> >
> 
> Given that you are using bash, my guess is that the below should do what
> you want:
> 
> STARTDIR=$(dirname $_)
> cd $STARTDIR || exit $?

My point is that all of this is unnecessary. For one, tar doesn't
change the current working directory all by itself. For two, if
all of that is run as a subshell, whatever change wouldn't propagate
"upstream".

Occam's razor.

Cheers
-- t


signature.asc
Description: Digital signature


Re: Script does not do what it is told to do

2019-10-25 Thread john doe
On 10/25/2019 9:16 AM, to...@tuxteam.de wrote:
> On Fri, Oct 25, 2019 at 02:40:00AM +0200, deloptes wrote:
>> Ken Heard wrote:
>>
>>> Whenever I run this script -- or several others like it
>>>
>>> #!/bin/bash
>>> # Script to back up all browser files in directory /home/ken/mozilla.
>>> STARTDIR=$PWD
>>> cd /home/ken
>>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
>>> --wildcards -T docs/tarlists/kbrowsers.lst
>>> cd "$STARTDIR"
>>>
>>> it returns the following:
>>>
>>
>> this is not possible because in the script you tell tar to create archive
>> in /media/fde/backups/
>
> Possibly /media/fde is a (broken) symbolic link to /media/ssda?
>
> Besides (but this probably hasn't to do with your failure):
> what are you trying to achieve with 'STARTDIR=$PWD' and then
> 'cd "$STARTDIR"'?
>

Given that you are using bash, my guess is that the below should do what
you want:

STARTDIR=$(dirname $_)
cd $STARTDIR || exit $?

--
John Doe



Re: Script does not do what it is told to do

2019-10-25 Thread Michael Howard

On 24/10/2019 23:37, Ken Heard wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Whenever I run this script -- or several others like it

#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
STARTDIR=$PWD
cd /home/ken
tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
- --wildcards -T docs/tarlists/kbrowsers.lst
cd "$STARTDIR"

it returns the following:

ken@Turing:~$ tarkbrowsers
tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
file or directory
tar (child): Error is not recoverable: exiting now
tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
tar: Child returned status 2
tar: Error is not recoverable: exiting now

It is trying to save the tarball to a different portable storage
device, ssda, which had failed and consequently is no longer in
/etc/fstab.  How could such a thing happen?


There is nothing inherently wrong with the script, in that it would work 
if all other things were equal, but they are clearly not.


Do an 'ls -l' on '/media/fde/backups', does it reveal anything? It might 
well do.


Using the -C option to tar is preferable to the way you are doing it.  So,

tar -czf /media/fde/backups/kbrowsers.tgz --exclude-caches --wildcards -C 
/home/ken
 -T ./docs/tarlists/kbrowsers.lst

might be better. You  will return to your starting location then, 
without the need for STARTDIR gubbings.


Mike.

--




Re: Script does not do what it is told to do

2019-10-25 Thread deloptes
Ken Heard wrote:

> the archive.  It is properly mounted, and I can write files to it and
> read those files.  As I said in my original post I am able to write
> the archive successfully to /media/fde/backups/ by copying the tar
> command line to a console and read the contents of the tarball.
> 

now there is difference 
- /media/fde/
+ /media/ssda/

In the script portion you pasted it is not visible that the disk is
dynamically set

tar -czf /media/fde/backups/kbrowsers.tgz 

How does it comes that you have different in the script and in the output


I recall that in debian since some time the mount changed from

/media/

to 

/media//





Re: Script does not do what it is told to do

2019-10-25 Thread tomas
On Fri, Oct 25, 2019 at 02:40:00AM +0200, deloptes wrote:
> Ken Heard wrote:
> 
> > Whenever I run this script -- or several others like it
> > 
> > #!/bin/bash
> > # Script to back up all browser files in directory /home/ken/mozilla.
> > STARTDIR=$PWD
> > cd /home/ken
> > tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> > --wildcards -T docs/tarlists/kbrowsers.lst
> > cd "$STARTDIR"
> > 
> > it returns the following:
> > 
> 
> this is not possible because in the script you tell tar to create archive
> in /media/fde/backups/

Possibly /media/fde is a (broken) symbolic link to /media/ssda?

Besides (but this probably hasn't to do with your failure):
what are you trying to achieve with 'STARTDIR=$PWD' and then
'cd "$STARTDIR"'?

Cheers
-- tomás


signature.asc
Description: Digital signature


Re: Script does not do what it is told to do

2019-10-24 Thread The Wanderer
On 2019-10-24 at 18:37, Ken Heard wrote:

> Whenever I run this script -- or several others like it



> it returns the following:
> 
> ken@Turing:~$ tarkbrowsers
> tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
> file or directory

How are you invoking the script?

What does

$ type tarkbrowsers

report?

Does running the script with its full path, rather than by the bare
name, make any difference?

I'm wondering whether there might somehow be another script with this
same name, which is in your PATH ahead (and therefore getting invoked
instead) of the one you quoted for us.

No idea how that might have gotten to be the case, if so, but it's at
least worth explicitly ruling out.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw



signature.asc
Description: OpenPGP digital signature


Re: Script does not do what it is told to do

2019-10-24 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-24 8:40 p.m., deloptes wrote:
> Ken Heard wrote:
> 
>> Whenever I run this script -- or several others like it
>> 
>> #!/bin/bash # Script to back up all browser files in directory
>> /home/ken/mozilla. STARTDIR=$PWD cd /home/ken tar -czf
>> /media/fde/backups/kbrowsers.tgz  --exclude-caches \ --wildcards
>> -T docs/tarlists/kbrowsers.lst cd "$STARTDIR"
>> 
>> it returns the following:
>> 
> 
> this is not possible because in the script you tell tar to create
> archive in /media/fde/backups/

Yes, that is the location where I want the archive kbrowsers.tgz to be
put.

>> ken@Turing:~$ tarkbrowsers tar (child):
>> /media/ssda/backups/kbrowsers.tgz: Cannot open: No such file or
>> directory tar (child): Error is not recoverable: exiting now tar:
>> /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe tar:
>> Child returned status 2 tar: Error is not recoverable: exiting
>> now
>> 
> 
> and here you are failing to write
> /media/ssda/backups/kbrowsers.tgz

/media/ssda/ .. does not exist, neither as a directory or in /etc/fstab

>> It is trying to save the tarball to a different portable storage 
>> device, ssda, which had failed and consequently is no longer in 
>> /etc/fstab.  How could such a thing happen?
>> 
> 
> obviously it is another script or whatever

But how?

>> However, if I pull the line with the tar command out of the
>> script and running it independently it does what it is told.  If
>> there is something wrong with the script I can't find it.
>> 
>> I also tried the script with the second line reading
>> STARTDIR="$PWD"; but that change made no difference, the result
>> was the same.
>> 
> 
> The question is where do you want to write the data - if on media
> attached then create entry in /etc/fstab so that you can mount it
> in consistent way, change the script and the problem will be gone.

/media/fde is the mount point for the device to which will be written
the archive.  It is properly mounted, and I can write files to it and
read those files.  As I said in my original post I am able to write
the archive successfully to /media/fde/backups/ by copying the tar
command line to a console and read the contents of the tarball.

> I have seen all kind of stupid and ugly admin scripts, where the
> author himself does not know how or why it is or it is not working
> at the end.
> 
> regards

Regards, Ken



-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXbJjwQAKCRCU2UnM6QmZ
NzIJAJ9Ng8JazKDR52yEBcyEoatQBu7PQACcCT5xNctrkAiobqpPGG1Soj9lmCI=
=fv+M
-END PGP SIGNATURE-



Re: Script does not do what it is told to do

2019-10-24 Thread deloptes
Ken Heard wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> On 2019-10-24 7:12 p.m., Anuradha Weeraman wrote:
> 
>> On Thu, Oct 24, 2019 at 06:37:08PM -0400, Ken Heard wrote:
>>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \ -
>>> --wildcards -T docs/tarlists/kbrowsers.lst
>> 
>> Try removing the single '-' at the beginning of the second line...
> 
> In this instance it does not matter whether that '-' is there or not.
>  Pulling that line out of the script and running it independently
> works both with and without it.
> 


In the original post I did not see any dash screenshot attached





Re: Script does not do what it is told to do

2019-10-24 Thread Ken Heard
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2019-10-24 7:12 p.m., Anuradha Weeraman wrote:

> On Thu, Oct 24, 2019 at 06:37:08PM -0400, Ken Heard wrote:
>> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \ -
>> --wildcards -T docs/tarlists/kbrowsers.lst
> 
> Try removing the single '-' at the beginning of the second line...

In this instance it does not matter whether that '-' is there or not.
 Pulling that line out of the script and running it independently
works both with and without it.

Regards, Ken



-BEGIN PGP SIGNATURE-

iF0EARECAB0WIQR9YFyM2lJAhDprmoOU2UnM6QmZNwUCXbJHlQAKCRCU2UnM6QmZ
N9CyAJ0V2UNi7X6qEj+oTe24JWYyksnm/gCff2SSNSfy8oFTt6wS9R+8f5HupZY=
=nMke
-END PGP SIGNATURE-



Re: Script does not do what it is told to do

2019-10-24 Thread deloptes
Ken Heard wrote:

> Whenever I run this script -- or several others like it
> 
> #!/bin/bash
> # Script to back up all browser files in directory /home/ken/mozilla.
> STARTDIR=$PWD
> cd /home/ken
> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> --wildcards -T docs/tarlists/kbrowsers.lst
> cd "$STARTDIR"
> 
> it returns the following:
> 

this is not possible because in the script you tell tar to create archive
in /media/fde/backups/

> ken@Turing:~$ tarkbrowsers
> tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
> file or directory
> tar (child): Error is not recoverable: exiting now
> tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
> tar: Child returned status 2
> tar: Error is not recoverable: exiting now
> 

and here you are failing to write /media/ssda/backups/kbrowsers.tgz

> It is trying to save the tarball to a different portable storage
> device, ssda, which had failed and consequently is no longer in
> /etc/fstab.  How could such a thing happen?
> 

obviously it is another script or whatever

> However, if I pull the line with the tar command out of the script and
> running it independently it does what it is told.  If there is
> something wrong with the script I can't find it.
> 
> I also tried the script with the second line reading STARTDIR="$PWD";
> but that change made no difference, the result was the same.
> 

The question is where do you want to write the data - if on media attached
then create entry in /etc/fstab so that you can mount it in consistent way,
change the script and the problem will be gone.

I have seen all kind of stupid and ugly admin scripts, where the author
himself does not know how or why it is or it is not working at the end.

regards




Re: Script does not do what it is told to do

2019-10-24 Thread Anuradha Weeraman
On Thu, Oct 24, 2019 at 06:37:08PM -0400, Ken Heard wrote:
> tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
> - --wildcards -T docs/tarlists/kbrowsers.lst

Try removing the single '-' at the beginning of the second line...

-- 
Regards
Anuradha



Re: Script Iptables pour serveur web Apache2 MySQL ProFTPD avec Port Knocking pour SSH

2019-09-25 Thread Pascal Hambourg

Le 25/09/2019 à 14:14, G2PC a écrit :



# J'enlève la valeur SYN et l'accès web et terminal fonctionne
correctement.
-A PREROUTING -p tcp -m multiport --dports 22,80,443 -m tcp
--tcp-flags FIN,RST,ACK SYN -j CT --notrack


Cette règle n'a aucune chance de s'appliquer puisque la combinaison
masque/drapeaux est impossible. Tu testes un drapeau qui n'est pas
dans le masque, ça ne peut pas marcher.

Hum. Bon, je te crois, je commente donc cette règle, le temps d'avoir
plus d'informations sur raw et les règles conseillées.
Est ce que le masque avec le SYN (que j'ai retiré) " FIN,SYN,RST,ACK SYN
" est plus cohérente que " FIN,RST,ACK SYN " ?


Bien sûr. C'est de l'algèbre booléenne de base. La seconde liste de 
--tcp-flags doit être incluse dans la première liste.
"FIN,RST,ACK SYN" signifie "conserver les valeurs des drapeaux FIN, RST 
et ACK et mettre à 0 les autres (dont SYN), puis renvoyer vrai si dans 
le résultat SYN=1 (ce qui est impossible) et tous les autres à 0".



Comme dit, avec le SYN en deuxième position, les accès sont coupés une
fois que je place la règle *filter


L'état UNTRACKED doit interférer soit avec le filtrage en entrée, soit 
avec le filtrage en sortie. Si un paquet SYN a été classé UNTRACKED, 
alors les paquets suivants de la poignée de main (SYN+ACK sortant et ACK 
entrant) sont classés par défaut dans l'état INVALID.



# Je ne sais pas si il est nécessaire d'autoriser le loopback vers
l'extérieur, voir à trouver un exemple.


Cette phrase n'a aucun sens puisque le trafic envoyé sur l'interface
de loopback ne va pas vers l'extérieur mais revient.


Tu parles de mon commentaire concernant la règle OUTPUT qui n'a pas de
sens, dès lors ?


Je parle de la phrase ci-dessus que j'ai laissée.


-A OUTPUT -m conntrack ! --ctstate INVALID -j ACCEPT


Typiquement, le paquet de réponse SYN/ACK à un paquet SYN dans l'état
UNTRACKED (à cause de -j CT --notrack) serait classé par défaut dans
l'état INVALID. Je ne connais pas l'interaction éventuelle avec SYNPROXY.


Je ne sais pas comment appréhender ce retour.
Le -j CT --notrack est dans la ligne qui a été désactivée dans la table *raw
A suivre.


Tu pourrais accepter les paquets SYN+ACK sortants ayant un des ports 
source concernés par le SYNPROXY.



# Autoriser les connexions DNS.
-A INPUT -p tcp --dport 53 -j ACCEPT


La machine fait serveur DNS pour l'extérieur ?


Je ne pense pas ? C'est à dire, est ce qu'elle transmet des informations
vers un autre service extérieur ?


C'est-à-dire qu'elle répond à des requêtes DNS.


Hormis les pages web, non, donc, si je t'entend bien, je peux supprimer
les règles DNS ?


Il vaut mieux ne pas supprimer les règles qui acceptent les requêtes DNS 
en sortie.



Qu'est-ce que la connexion fstp ?

Oups ! sFTP


Ça utilise SSH, donc rien à voir avec le protocole FTP.


-A OUTPUT -p tcp --sport 21 -m state --state ESTABLISHED -j LOG_ACCEPT
-A OUTPUT -p tcp --sport 49152:65534 --dport 49152:65534 -m state
--state ESTABLISHED -j LOG_ACCEPT


Inutiles puisque ces paquets ont déjà été acceptés par la règle
générique qui autorise les connexions déjà établies.
De toute façon, serait-il vraiment nécessaire de loguer ces paquets ?


ça fait beaucoup de paquets à loguer ?


Ça loguerait tous les paquets sortants des connexions de commande et de 
données FTP, soit grosso modo un paquet par commande FTP et un paquet 
par bloc de 1400 octets de données de fichier téléchargé ou de contenu 
de répertoire lu. Je ne vois pas l'intérêt, loguer le premier paquet suffit.



Le client me dit ceci, on observe que j'arrive bien à me connecter la
première fois, puis, sur un second compte il n'arrive pas à récupérer le
contenu du dossier.
Je me reconnecte au second compte, et, il arrive alors a récupérer le
contenu du dossier. Vraiment étrange.
Statut :    Connexion à 139.99.173.195:21...
Statut :    Connexion établie, attente du message d'accueil...
Statut :    Initialisation de TLS...
Statut :    Vérification du certificat...
Statut :    Connexion TLS établie.


Note : si tu utilises TLS avec FTP, alors le module de suivi de 
connection nf_conntrack mentionné dans mon message précédent est aveugle 
et inutile.



Statut :    Récupération du contenu du dossier...
Commande :    PWD
Réponse :    257 "/" est le répertoire courant
Commande :    TYPE I
Réponse :    200 Type paramétré à I
Commande :    PASV
Réponse :    227 Entering Passive Mode (139,99,173,195,202,139).
Commande :    LIST
Erreur :    Connection interrompue après 20 secondes d'inactivité


Il faudrait vérifier le port source utilisé par le client pour la 
connexion de données servant au listage. Attention : si le client est 
derrière un dispositif NAT (routeur, box), ce dernier peut modifier le 
port source à la volée. Regarde dans les logs générés par iptables.



-A INPUT -p tcp --dport 21 -m state --state NEW,ESTABLISHED -j
LOG_ACCEPT
-A INPUT -p tcp --sport 49152:65534 --dport 49152:65534 -m state
--state ESTABLISHED,RELATED,NEW -j LOG_ACCEPT


Côté serveur, tu ne 

Re: Script Iptables pour serveur web Apache2 MySQL ProFTPD avec Port Knocking pour SSH

2019-09-25 Thread G2PC

>>
>> Par exemple, pour ProFTPD, il me semble avoir configuré correctement le
>> service, mais, le client FileZilla ne semble pas réussir à se connecter
>> lors de toutes ses tentatives.
>> Actuellement, j'arrive régulièrement à me connecter au client FTP, mais,
>> pas à 100%.
>> Je précise, ce n'est pas la connexion qui semble bloquer
>> occasionnellement, mais, la lecture des dossiers une fois connecté,
>> d'après ce que je lis sur FileZilla.
>
> Donc les connexions de données avec les ports de destination dynamiques.
> Est-ce que tu as chargé le module de suivi de connexion FTP
> nf_conntrack_ftp ?
> Si oui, est-ce que tu as réglé l'option nf_conntrack_helper du module
> nf_conntrack à 1 puisque je ne vois pas de règle avec CT --helper pour
> affecter explicitement le helper ftp aux connexions de commande FTP ?

Alors la, bonne question !
J'ai vu passer ce mot clé " conntrack, quelques fois ses derniers jours,
mais, je ne crois pas avoir fait quoi que ce soit à ce niveau.
Je vais chercher. Merci.

>> *raw
>>
>> # Anti DDOS.
>> # Les paquets TCP avec le flag SYN à destination des ports 22,80 ou
>> 443 ne seront pas suivi par le connexion tracker et donc traités plus
>> rapidement.
>> ## Les pages ne chargent plus avec cette règle de décommentée tout
>> comme la connexion SSH devient impossible !
>
> En temps normal, ce n'est pas seulement le paquet SYN mais tous les
> paquets suivants (entrants et sortants) qu'il faut exclure du suivi de
> connexion et accepter. Par contre j'ai vu que tu utilises SYNPROXY qui
> interagit avec le suivi de connexion, mais je ne connais pas bien.

Comme dit, pour raw, j'ai enlevé ce filtrage sur SYN, car, j'ai un
conflit avec *filter à ce moment la, et, je ne peux plus naviguer sur
les pages, ni me connecter via SSH avec ma règle Port Knocking.
J'ai repris une règle présentée dans un tutoriel, et, je l'ai laissée
ainsi, en retirant SYN.
Idem, j'ai peu d'informations sur raw et sur ses paquets a supprimer
depuis raw.

>> # J'enlève la valeur SYN et l'accès web et terminal fonctionne
>> correctement.
>> -A PREROUTING -p tcp -m multiport --dports 22,80,443 -m tcp
>> --tcp-flags FIN,RST,ACK SYN -j CT --notrack
>
> Cette règle n'a aucune chance de s'appliquer puisque la combinaison
> masque/drapeaux est impossible. Tu testes un drapeau qui n'est pas
> dans le masque, ça ne peut pas marcher.
Hum. Bon, je te crois, je commente donc cette règle, le temps d'avoir
plus d'informations sur raw et les règles conseillées.
Est ce que le masque avec le SYN (que j'ai retiré) " FIN,SYN,RST,ACK SYN
" est plus cohérente que " FIN,RST,ACK SYN " ?
Comme dit, avec le SYN en deuxième position, les accès sont coupés une
fois que je place la règle *filter, par contre, le site est fonctionnel
si je ne met QUE les restrictions dans la table *raw , de ce fait, je
pense à un effet de bord entre mes règles raw et filter.

>> # On pourrait interdire le ping avec icmp directement en PREROUTING.
>> # Pour le moment je vais l'interdire par défaut depuis *filter et
>> autoriser le ping aux services OVH.
>> # -A PREROUTING -p icmp -j DROP
>
> Erreur fréquente : ICMP, ce n'est pas seulement le ping mais aussi des
> messages d'erreur qu'il vaut mieux ne pas bloquer si on veut que les
> communications marchent bien.
Ok je prend note, j'ajoute ce commentaire au dessus de la ligne commentée.
>> # Pas de filtrage sur l'interface de loopback.
>> 
>> # Le serveur ne doit pas avoir de soucis à communiquer avec lui-même
>> au niveau des services internes.
>> # Accepter toutes les connexions de la machine locale pour permettre
>> aux services de communiquer entre eux.
>> -A INPUT -i lo -j ACCEPT
>> # Par la suite, la règle par défaut va DROP sur tous les OUTPUT non
>> autorisés.
>> # Je ne sais pas si il est nécessaire d'autoriser le loopback vers
>> l'extérieur, voir à trouver un exemple.
>
> Cette phrase n'a aucun sens puisque le trafic envoyé sur l'interface
> de loopback ne va pas vers l'extérieur mais revient.
Tu parles de mon commentaire concernant la règle OUTPUT qui n'a pas de
sens, dès lors ?

> # L'absence d'autorisation en sortie peut t'elle interférer avec
> certains services attendant une communication en sortie de loopback ?
>> # -A OUTPUT -o lo -j ACCEPT
OK, je décommente donc la règle OUTPUT pour le loopback. Merci.

>
> Evidemment ça interfère. Tout paquet envoyé sur l'interface de
> loopback passe successivement par les chaînes OUTPUT, POSTROUTING,
> PREROUTING et INPUT et doit être accepté dans toutes pour arriver à
> destination.
>
>> -A OUTPUT -m conntrack ! --ctstate INVALID -j ACCEPT
>
> Typiquement, le paquet de réponse SYN/ACK à un paquet SYN dans l'état
> UNTRACKED (à cause de -j CT --notrack) serait classé par défaut dans
> l'état INVALID. Je ne connais pas l'interaction éventuelle avec SYNPROXY.
Je ne sais pas comment appréhender ce retour.
Le -j CT --notrack est dans la ligne qui a été désactivée dans la table *raw
A suivre.

>
>> 
>> # Autoriser les services web.
>> 
>> # 

Re: Script Iptables pour serveur web Apache2 MySQL ProFTPD avec Port Knocking pour SSH

2019-09-25 Thread Pascal Hambourg

Le 24/09/2019 à 23:46, G2PC a écrit :


Par exemple, pour ProFTPD, il me semble avoir configuré correctement le
service, mais, le client FileZilla ne semble pas réussir à se connecter
lors de toutes ses tentatives.
Actuellement, j'arrive régulièrement à me connecter au client FTP, mais,
pas à 100%.
Je précise, ce n'est pas la connexion qui semble bloquer
occasionnellement, mais, la lecture des dossiers une fois connecté,
d'après ce que je lis sur FileZilla.


Donc les connexions de données avec les ports de destination dynamiques.
Est-ce que tu as chargé le module de suivi de connexion FTP 
nf_conntrack_ftp ?
Si oui, est-ce que tu as réglé l'option nf_conntrack_helper du module 
nf_conntrack à 1 puisque je ne vois pas de règle avec CT --helper pour 
affecter explicitement le helper ftp aux connexions de commande FTP ?



*raw

# Anti DDOS.
# Les paquets TCP avec le flag SYN à destination des ports 22,80 ou 443 ne 
seront pas suivi par le connexion tracker et donc traités plus rapidement.
## Les pages ne chargent plus avec cette règle de décommentée tout comme la 
connexion SSH devient impossible !


En temps normal, ce n'est pas seulement le paquet SYN mais tous les 
paquets suivants (entrants et sortants) qu'il faut exclure du suivi de 
connexion et accepter. Par contre j'ai vu que tu utilises SYNPROXY qui 
interagit avec le suivi de connexion, mais je ne connais pas bien.



# J'enlève la valeur SYN et l'accès web et terminal fonctionne correctement.
-A PREROUTING -p tcp -m multiport --dports 22,80,443 -m tcp --tcp-flags 
FIN,RST,ACK SYN -j CT --notrack


Cette règle n'a aucune chance de s'appliquer puisque la combinaison 
masque/drapeaux est impossible. Tu testes un drapeau qui n'est pas dans 
le masque, ça ne peut pas marcher.



# On pourrait interdire le ping avec icmp directement en PREROUTING.
# Pour le moment je vais l'interdire par défaut depuis *filter et autoriser le 
ping aux services OVH.
# -A PREROUTING -p icmp -j DROP


Erreur fréquente : ICMP, ce n'est pas seulement le ping mais aussi des 
messages d'erreur qu'il vaut mieux ne pas bloquer si on veut que les 
communications marchent bien.



# Pas de filtrage sur l'interface de loopback.

# Le serveur ne doit pas avoir de soucis à communiquer avec lui-même au niveau 
des services internes.
# Accepter toutes les connexions de la machine locale pour permettre aux 
services de communiquer entre eux.
-A INPUT -i lo -j ACCEPT
# Par la suite, la règle par défaut va DROP sur tous les OUTPUT non autorisés.
# Je ne sais pas si il est nécessaire d'autoriser le loopback vers l'extérieur, 
voir à trouver un exemple.


Cette phrase n'a aucun sens puisque le trafic envoyé sur l'interface de 
loopback ne va pas vers l'extérieur mais revient.



# L'absence d'autorisation en sortie peut t'elle interférer avec certains 
services attendant une communication en sortie de loopback ?
# -A OUTPUT -o lo -j ACCEPT


Evidemment ça interfère. Tout paquet envoyé sur l'interface de loopback 
passe successivement par les chaînes OUTPUT, POSTROUTING, PREROUTING et 
INPUT et doit être accepté dans toutes pour arriver à destination.



-A OUTPUT -m conntrack ! --ctstate INVALID -j ACCEPT


Typiquement, le paquet de réponse SYN/ACK à un paquet SYN dans l'état 
UNTRACKED (à cause de -j CT --notrack) serait classé par défaut dans 
l'état INVALID. Je ne connais pas l'interaction éventuelle avec SYNPROXY.




# Autoriser les services web.

# Autoriser les connexions DNS.
-A INPUT -p tcp --dport 53 -j ACCEPT


La machine fait serveur DNS pour l'extérieur ?


-A INPUT -p udp --sport 53 -j ACCEPT


Cette règle est une faille de sécurité en plus d'être inutile.


# Configurer le FTP et le pare-feu pour utiliser la plage de ports passifs 
entre 49152-65534 proposée par IANA.
# Noter que la connexion de semble pas s'établir à chaque fois et qu'il est 
nécessaire de retenter la connexion.
# Noter que la connexion fstp n'est pas configurée actuellement. A faire !


Qu'est-ce que la connexion fstp ?


-A OUTPUT -p tcp --sport 21 -m state --state ESTABLISHED -j LOG_ACCEPT
-A OUTPUT -p tcp --sport 49152:65534 --dport 49152:65534 -m state --state 
ESTABLISHED -j LOG_ACCEPT


Inutiles puisque ces paquets ont déjà été acceptés par la règle 
générique qui autorise les connexions déjà établies.

De toute façon, serait-il vraiment nécessaire de loguer ces paquets ?


-A INPUT -p tcp --dport 21 -m state --state NEW,ESTABLISHED -j LOG_ACCEPT
-A INPUT -p tcp --sport 49152:65534 --dport 49152:65534 -m state --state 
ESTABLISHED,RELATED,NEW -j LOG_ACCEPT


Côté serveur, tu ne maîtrises pas la plage de ports du client. 
Restreindre les ports source du client à la même plage que celle du 
serveur est abusif.



# Autoriser les connexions au serveur web Apache2.
-A INPUT -p tcp --dport 80 -j ACCEPT
-A OUTPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
-A OUTPUT -p tcp --dport 443 -j ACCEPT


Maintenant que ces paquets sont acceptées, toutes les règles suivantes 

Re: Script para ejecutar un comando en cada directorio

2018-09-05 Thread Antonio Galicia
El 4 de septiembre de 2018, 15:22, Josu
Lazkano escribió:

> El arbol de directorios sera asi:
>
> /fotos/
> /fotos/2018-01 - Viaje a noseque/
> /fotos/2018-03 - Cena de amigos/
> /fotos/2018-08 - Verano con la familia/
>
> El comando es el siguiente:
>
> mogrify -delete 1 -format jpg -- *.tif

Hola, buen día.

Intenta con algo así:

find {path} -type d | while read p; do cd "$p"; mogrify -delete 1
-format jpg -- *.tif ; done

El {path} siempre lo debes colocarlo con la ruta abasoluta dado que va
a estar cambiando y puede que no lo encuentre si lo indicas de manera
relativa.

Esto es, la ruta la debes poner "/home/user/fotos" y no hacer un cd
/home/user y poner "fotos" como path

Y claro, puedes hacer

find fotos -type f -name '*.tif' -print0 | xargs -0 mogrify
-delete 1 -format jpg --

El print0 es para que los espacios en los nombres no genere problema

Uno de los dos te debe servir, espero

 Saludos,
 Antonio Galicia

Eram quod es, eris quod sum
--



Re: Script para ejecutar un comando en cada directorio

2018-09-05 Thread julher



> El 4 sept 2018, a las 22:22, Josu Lazkano  escribió:
> 
> Buenas,
> 
> Me estoy volviendo loco con un pequeño problema que tengo.
> 
> Tengo que convertir un montón de fotos que tengo ordenados en
> directorios. Lo que quiero es ejecutar un script en la raiz de un
> directorio, y que se ejecute un comando dentro de cada directorio.
> 
> El arbol de directorios sera asi:
> 
> /fotos/
> /fotos/2018-01 - Viaje a noseque/
> /fotos/2018-03 - Cena de amigos/
> /fotos/2018-08 - Verano con la familia/
> 
> El comando es el siguiente:
> 
> mogrify -delete 1 -format jpg -- *.tif
> 
> Como puedo hacer un bash que ejecutado en el directorio /fotos/, pueda
> entrar cada directorio y ejecutar ese comando?
> 
> Otra forma seria cambiar el comnado para fuese algo asi: (con la
> variable $directorio)
> 
> mogrify -delete 1 -format jpg -- $directorio/*.tif
> 
> ¿alguien me puede ayudar con esto?


Hola,

Una forma de hacerlo es mediante un script, algo así:

#!/bin/bash
cd fotos
for i in $(ls -R); do
   mogrify --parametros --que --necesites $i
done

Igual falta algún ; o algo...

Un saludo

JulHer




Re: Script para ejecutar un comando en cada directorio

2018-09-04 Thread fernando sainz
El día 4 de septiembre de 2018, 22:22, Josu Lazkano 
escribió:
> Buenas,
>
> Me estoy volviendo loco con un pequeño problema que tengo.
>
> Tengo que convertir un montón de fotos que tengo ordenados en
> directorios. Lo que quiero es ejecutar un script en la raiz de un
> directorio, y que se ejecute un comando dentro de cada directorio.
>
> El arbol de directorios sera asi:
>
> /fotos/
> /fotos/2018-01 - Viaje a noseque/
> /fotos/2018-03 - Cena de amigos/
> /fotos/2018-08 - Verano con la familia/
>
> El comando es el siguiente:
>
> mogrify -delete 1 -format jpg -- *.tif
>
> Como puedo hacer un bash que ejecutado en el directorio /fotos/, pueda
> entrar cada directorio y ejecutar ese comando?
>
> Otra forma seria cambiar el comnado para fuese algo asi: (con la
> variable $directorio)
>
> mogrify -delete 1 -format jpg -- $directorio/*.tif
>
> ¿alguien me puede ayudar con esto?
>
> Gracias por todo.
>
> Un saludo.
>
> --
> Josu Lazkano
>

Hola.

Te doy una pista, con el comando  find con la opción -exec o con | xargs.

https://www.everythingcli.org/find-exec-vs-find-xargs/

S2.


Re: script bash pour unbound

2018-08-21 Thread Bernard Schoenacker



- Mail original -
> De: "Daniel Caillibaud" 
> À: debian-user-french@lists.debian.org
> Envoyé: Mardi 21 Août 2018 19:21:06
> Objet: Re: script bash pour unbound
> 
> Le 18/08/18 à 21:48, Bernard Schoenacker
>  a
> écrit :
> 
> > bonjour,
> > 
> > j'ai pris ce script bash et je n'arrive pas à le déverminer:
> > 
> > https://blog.mirabellette.eu/index.php?article17/block-advertise-domain-name-with-unbound
> > 
> > voici le début qui pose problème :
> > 
> > ARRAY=
> > $(https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
> > )
> 
> sur la page mentionnée y'a pas de $
> 
> > for i in "${ARRAY[@]}"
> 
> et du coup je comprend pas la ligne précédente, pourquoi un for sur
> un
> tableau d'un seul élément ?
> 
> Pas testé, mais amha, virer do/done et remplacer le wget par
> 
> > do
> >   wget -c  -O  w  "$i"
> 
> wget -c -O w
> https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
> 
> 
> > 
> >   grep -v "
> >   #\|\|\|\|\|\|href\|title=\|=\|<" w
> > > adsList.txt rm -f w
> >   dos2unix adsList.txt
> 
> 
> ça peut se faire sans fichier intermediaire avec
> 
> wget -c -O - $url|grep -v "expression" > fichier
> 
> donc ici tu peux te contenter de ces 3 lignes, en remplaçant la 3e
> par /etc/init, service ou systemctl suivant ta conf
> (et mettre le path complet de adsList.txt pour pouvoir lancer le
> script de
> n'importe où) :
> 
> url=https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
> wget -q -O - $url|sed -e '/^$/d; /#/d' > adsList.txt
> # reste à relancer unbound qui lit ce adsList.txt
> 
> 
> mais je crois qu'unbound ignore les lignes vides et celles qui
> commencent
> par #, ton script devrai#!/bin/bash
#
# set chmod +x
# exec sh

echo  Someonewhocares  Go ===

wget -vnc -O - 'https://someonewhocares.org/hosts/zero/' |unhtml | grep 
'^0\.0\.0\.0' | awk '/0.0.0.0/ {print $2}'| iconv -f iso8859-15 -t utf8 >>w

echo convert file to utf8
echo  Someonewhocares  done ==

echo  Githubusercontent notracking  Go 
===
wget -vnc -O - 
'https://raw.githubusercontent.com/notracking/hosts-blocklists/master/hostnames.txt'|
 grep '^0\.0\.0\.0' | awk '/0.0.0.0/ {print $2}'| iconv -f iso8859-15 -t utf8 
>>w

echo convert file to utf8
echo  Githubusercontent notracking  done 
===

echo  winhelp2002 Go ===

  wget -vnc -O - 'http://winhelp2002.mvps.org/hosts.txt' |awk '/0.0.0.0/ {print 
$2}'| iconv -f iso8859-15 -t utf8 >>w
 
echo convert file to utf8
echo  winhelp2002 done ===


echo  Githubusercontent StevenBlack Go 
===

wget -vnc -O - 
'https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts'
 |awk '/0.0.0.0/ {print $2}'| iconv -f iso8859-15 -t utf8 >>w

echo convert file to utf8
echo  Githubusercontent StevenBlack done 
===

echo  Adaway  Go ===
wget -vnc -O -  'https://adaway.org/hosts.txt' | awk '/127.0.0.1/ {print $2}'| 
iconv -f iso8859-15 -t utf8 >>w
echo convert file to utf8
echo  Adaway  done ===


echo  Pgl Yoyo  Go ===
wget -vnc  -O- --header\="Accept-Encoding: gzip" 
'http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts=plaintext'
 | gunzip | awk '/127.0.0.1/ {print $2}'| iconv -f iso8859-15 -t utf8 >>w

echo convert file to utf8
echo  Pgl Yoyo  done ===


echo  Hosts File  Go ===
wget -qnc  -O - 'https://hosts-file.net/ad_servers.txt' | awk '/127.0.0.1/ 
{print $2}' | iconv -f iso8859-15 -t utf8 >>w

echo convert file to utf8
echo  Hosts File done ===


echo   dsfc  Go ===

wget -qnc -O - 
'https://www.dsfc.net/infrastructure/dns-infrastructure/unbound-redirecteur-cache-blacklist-dns/'|unhtml|
 tr -d '\'| tr -d '"' | awk '/local-zone/ {print $2}'| iconv -f iso8859-15 
-t utf8 >>w

echo convert file to utf8
echo  dsfc  done ===


echo remove tabulation character and carriage return

sed -i 's/\x0D$//' w

echo  remove comments
sed -i 's/#//g' w

echo remove useless space
sed -i 's/ /

Re: script bash pour unbound

2018-08-21 Thread Daniel Caillibaud
Le 18/08/18 à 21:48, Bernard Schoenacker  a
écrit :

> bonjour,
> 
> j'ai pris ce script bash et je n'arrive pas à le déverminer:
> 
> https://blog.mirabellette.eu/index.php?article17/block-advertise-domain-name-with-unbound
> 
> voici le début qui pose problème :
> 
> ARRAY=
> $(https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
> )

sur la page mentionnée y'a pas de $

> for i in "${ARRAY[@]}"

et du coup je comprend pas la ligne précédente, pourquoi un for sur un
tableau d'un seul élément ?

Pas testé, mais amha, virer do/done et remplacer le wget par

> do
>   wget -c  -O  w  "$i"

wget -c -O w
https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts


> 
>   grep -v " #\|\|\|\|\|\|href\|title=\|=\|<" w
> > adsList.txt rm -f w
>   dos2unix adsList.txt


ça peut se faire sans fichier intermediaire avec

wget -c -O - $url|grep -v "expression" > fichier

donc ici tu peux te contenter de ces 3 lignes, en remplaçant la 3e
par /etc/init, service ou systemctl suivant ta conf
(et mettre le path complet de adsList.txt pour pouvoir lancer le script de
n'importe où) :

url=https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
wget -q -O - $url|sed -e '/^$/d; /#/d' > adsList.txt
# reste à relancer unbound qui lit ce adsList.txt


mais je crois qu'unbound ignore les lignes vides et celles qui commencent
par #, ton script devrait pouvoir se résumer à

url=https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
wget -q -O /path/to/adsList.tmp $url \
  && [ -s /path/to/adsList.tmp ] \
  && mv /path/to/adsList.tmp /path/to/adsList.txt \
  && systemctl reload unbound \
  && echo "Liste actualisée et rechargée" \
  || echo "Un truc a foiré">&2

(l'enchaînement avec && est là au cas où le wget plante, pour ne pas risquer
d'écraser l'ancien txt avec un truc vide, le test -s passe si le fichier
n'est pas vide)


Une remarque au passage, je ne laisserais pas qqun d'externe définir
l'ip de localhost, ça me parait plus prudent d'ajouter un sed pour virer
les premières lignes, ou ne garder que celles qui commencent par 0.0.0.0,
en ajoutant si besoin un autre fichier txt pour unbound pour ces lignes
(mais je crois qu'unbound résoud déjà localhost avec sa conf par défaut).

wget -q -O - $url|sed -ne '/^0\.0\.0\.0/ p' > /path/to/adsList.tmp


Celui qui fournit la liste pourra toujours rediriger localhost vers 0.0.0.0
mais au moins ça n'ira pas ailleurs et je vais m'en apercevoir rapidement.

> 
> 
> merci pour le coup de puce
> 
> slt
> bernard
> 


-- 
Daniel

Travailler dur n'a jamais tué personne, mais pourquoi prendre le 
risque ?
Edgar Bergen



Re: script bash pour unbound

2018-08-19 Thread Petrus MH8
Bonjour,

J'utilise actuellement un script un peu différent avec Unbound, pour une
finalité anti-pubs équivalente avec une autre source, je pense cependant
qu'il est possible de remanier la commande afin d'utiliser ta source si
tu préfères...
En espérant que ca fonctionne toujours sur la version Unbound distribuée
sur une Stretch, car actuellement sur une Raspbian 8 Jessie.

réf:
https://mh8.mooo.com/www/leminos/wiki/unbound-serveur-dns-a-la-maison-requetes-aux-dns-racines



Le 18/08/2018 à 21:48, Bernard Schoenacker a écrit :
> bonjour,
>
> j'ai pris ce script bash et je n'arrive pas à le déverminer:
>
> https://blog.mirabellette.eu/index.php?article17/block-advertise-domain-name-with-unbound
>
> voici le début qui pose problème :
>
> ARRAY= 
> $(https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
>  )
>
> for i in "${ARRAY[@]}"
> do
>   wget -c  -O  w  "$i"
>
>   grep -v " #\|\|\|\|\|\|href\|title=\|=\|<" w > 
> adsList.txt
>   rm -f w
>   dos2unix adsList.txt
>
>
> merci pour le coup de puce
>
> slt
> bernard
>






signature.asc
Description: OpenPGP digital signature


Re: script repos

2018-08-14 Thread Javier Debian




El 13/08/18 a las 05:44, t...@stg.hidro.cu escribió:

El 2018-08-13 04:00, t...@stg.hidro.cu escribió:

Buenas tardes alguien podría compartir un script para actualizar los
repos de debian...





> a ver no me exprese bien es un script para descargar los repos de 
debian...

>



http://es.lmgtfy.com/?iie=1=Creaci%C3%B3n+de+una+r%C3%A9plica+de+los+archivos+de+Debian



https://wiki.debian.org/es/NormasLista


https://es.wikipedia.org/wiki/Top-posting


JAP



Re: script repos

2018-08-13 Thread tony
a ver no me exprese bien es un script para descargar los repos de 
debian...


El 2018-08-13 04:00, t...@stg.hidro.cu escribió:

Buenas tardes alguien podría compartir un script para actualizar los
repos de debian...




Re: script repos

2018-08-13 Thread Fran Torres
Buenas,

Yo por lo menos no entiendo bien la consulta... pero si interpreto
bien, interpreto que quieres que los repos se actualicen
automáticamente. Por lo que, deberías agregar al crontab tras
completar los campos pertinetnes el siguiente comando:

apt-get update

Deberías tener vastante con eso;).

Fran.

El 13/8/18, t...@stg.hidro.cu  escribió:
> Buenas tardes alguien podría compartir un script para actualizar los
> repos de debian...
>
>



Re: script repos

2018-08-13 Thread Javier ArgentinaBBAR
El lun., 13 ago. 2018 a las 9:57,  escribió:
>
> Buenas tardes alguien podría compartir un script para actualizar los
> repos de debian...
>


#/bin/bash
apt update
apt list --upgradable
apt dist-upgrade -y
apt autoremove --purge -y
apt autoclean



Re: Script para monitorar conteúdo em uma página

2017-11-02 Thread henrique
deve resolver :D 


 wget -qO - https://www.mercadobitcoin.com.br/api/btc/ticker/ | sed 's/,/\n/g' 
| grep -i last | cut -d\" -f4
Abraços e divirta-se. 

Henry 

Em Quinta-feira, 2 de Novembro de 2017 15:42, Leandro Moreira 
 escreveu:
 

 Prezados, boa tarde!

Estou tentando monitorar com o zabbix o valor do bitcoin, para isso estou 
criando um script que o zabbix irá executar, esses script irá acessar a página 
no mercado biticoin (https://www.mercadobitcoin.com.br/) e coletar o valor em 
um intervalo pré-de definido (1,5 ou 10 minutos).

Já tentei criar esses script com lynx e com curl, mas em ambos os casos eles 
trazem toda a informação que tem na página menos o valor.

Podem me indicar o que pesquisar para conseguir criar esse script.

Att.

-- 
Leandro Moreira
Network Administrator
LPIC1 - Linux Professional Institute Certified
e-mail/msn: lean...@leandromoreira.eti.br
Tel.: + 55(32) 9906-5713

   

Re: Script con output de comando

2017-08-25 Thread Josu Lazkano
Muchas gracias!!!

if  echo 'pow 0' | cec-client -s -d 1 | grep "status: on"   >
/dev/null ; then echo prendida  ; else echo apagada ; fi

Me funciona perfectamente. El bash -x me viene muy bien para poder
depurar el codigo.

Un saludo a todos.

-- 
Josu Lazkano



Re: Script con output de comando

2017-08-24 Thread fernando sainz
El día 24 de agosto de 2017, 17:12, Josu Lazkano
 escribió:
> Buenas,
>
> Estoy intentando crear un script para poder comprobar el estado de mi TV
> mediante CEC.
>
> Lo que quiero es utilizar la salida de un comando para crear un script. El
> comando es el siguiente:
>
> # echo 'pow 0' | cec-client -s -d 1
>
> Y si la TV esta en marcha muestra:
>
> # echo 'pow 0' | cec-client -s -d 1
> opening a connection to the CEC adapter...
> power status: on
>
> Y si esta apagada muestra:
>
> # echo 'pow 0' | cec-client -s -d 1
> opening a connection to the CEC adapter...
> power status: standby
>
>
> Lo que quiero es hacer algo asi:
>
> if [[ $(echo 'pow 0' | cec-client -s -d 1) == "power status: standby" ]];
> then
>   echo "La TV está apagada"
> else
>   echo "La TV está en marcha"
> fi
>
> Pero no me funciona la condición del IF, ¿como puedo comprar una salida de
> un comando?
>
> Agradezco vuestra ayuda.
>
> Un saludo.
>
>
> --
> Josu Lazkano

Hola.
La sintaxis parece correcta, podría ser algún carácter de nueva linea
en la salida.

Prueba a depurarlo con:  bash -x script.sh
Esto te mostrará las cadenas que se comparan en el if y podrás ver el problema.

S2.



Re: Script con output de comando

2017-08-24 Thread Matias Mucciolo

On Thursday 24 August 2017 17:12:53 Josu Lazkano wrote:
> Buenas,
> 
> Estoy intentando crear un script para poder comprobar el estado de mi TV
> mediante CEC.
> 
> Lo que quiero es utilizar la salida de un comando para crear un script. El
> comando es el siguiente:
> 
> # echo 'pow 0' | cec-client -s -d 1
> 
> Y si la TV esta en marcha muestra:
> 
> # echo 'pow 0' | cec-client -s -d 1
> opening a connection to the CEC adapter...
> power status: on
> 
> Y si esta apagada muestra:
> 
> # echo 'pow 0' | cec-client -s -d 1
> opening a connection to the CEC adapter...
> power status: standby
> 
> 
> Lo que quiero es hacer algo asi:
> 
> if [[ $(echo 'pow 0' | cec-client -s -d 1) == "power status: standby" ]];
> then
>   echo "La TV está apagada"
> else
>   echo "La TV está en marcha"
> fi
> 
> Pero no me funciona la condición del IF, ¿como puedo comprar una salida de
> un comando?
> 
> Agradezco vuestra ayuda.
> 
> Un saludo.
> 
> 
> -- 
> Josu Lazkano



Buenas 


proba con eso 
es una sola linea
podes dividirlo en varias como un if/else comun

if  echo 'pow 0' | cec-client -s -d 1 | grep "status: on"   > /dev/null ; then 
echo prendida  ; else echo apagada ; fi

saludos.

Matias



Re: Script Bash de conversion ISO8859 -> UTF8

2017-02-20 Thread Haricophile
Le Sat, 18 Feb 2017 17:32:50 +0100,
"JF Straeten"  a écrit :


> On Sat, Feb 18, 2017 at 04:56:41PM +0100, Nicolas FRANCOIS wrote:
> 
> [...]
> > Merci les gars, ceci fonctionne comme je le veux :
> > 
> >   for filename in ` find . -type f -name "*.$1"`  
> 
> 
> Si le script s'exécute sous bash, tu devrais même éviter les backticks
> et recourir à la syntaxe $() qui fait la même chose en plus lisible et
> moins chiant quand il y a d'autres quotes :
> 
>  for filename in $(find . -type f -name "*.$1")

+1 d'autant que c'est la syntaxe préconisée, la syntaxe avec `` étant
considérée comme obsolète il me semble.



Re: Script Bash de conversion ISO8859 -> UTF8

2017-02-18 Thread JF Straeten

LO,


On Sat, Feb 18, 2017 at 04:56:41PM +0100, Nicolas FRANCOIS wrote:

[...]
> Merci les gars, ceci fonctionne comme je le veux :
> 
>   for filename in ` find . -type f -name "*.$1"`


Si le script s'exécute sous bash, tu devrais même éviter les backticks
et recourir à la syntaxe $() qui fait la même chose en plus lisible et
moins chiant quand il y a d'autres quotes :

 for filename in $(find . -type f -name "*.$1")


Hih,


-- 

JFS.



Re: Script Bash de conversion ISO8859 -> UTF8

2017-02-18 Thread φ Dhénin Jean-Jacques
On Sat, Feb 18, 2017 4:33 PM, Nicolas FRANCOIS nicolas.franc...@free.fr  wrote:
Salut.




[ … ]




  find: les chemins doivent précéder l'expression : arithmetique.tex




J'obtiens :




  for filename in ` find . -type f -name *.tex`




Même en essayant simplement de convertir les fichiers tex :


Find ne s'utilise pas comme cela, mais plutôt
find . -type f -name "*.tex" -exec iconv {} … \;
Attention le "\;" en fin de -exec est obligatoire !
Hope this help

-
(V) Dhénin Jean-Jacques
( ..) 48, rue de la Justice 78300 Poissy
c(')(')dhe...@gmail.com
-

Re: Script Bash de conversion ISO8859 -> UTF8

2017-02-18 Thread Nicolas FRANCOIS
Le Sat, 18 Feb 2017 16:33:49 +0100,
Nicolas FRANCOIS  a écrit :

Merci les gars, ceci fonctionne comme je le veux :

  for filename in ` find . -type f -name "*.$1"`

Merci à tous deux, avec un petit bonus à Jean-Jacques qui a été plus
rapide ;-) (mais Pascal a apporté une variante à la réponse, donc loué
soit-il, lui aussi !).

\bye

-- 

Nicolas FRANCOIS  |  /\ 
http://nicolas.francois.free.fr   | |__|
  X--/\\
We are the Micro$oft.   _\_V
Resistance is futile.   
You will be assimilated. darthvader penguin


pgp2GfAuDhb8B.pgp
Description: OpenPGP digital signature


Re: Script Bash de conversion ISO8859 -> UTF8

2017-02-18 Thread Pascal Obry
Le samedi 18 février 2017 à 16:33 +0100, Nicolas FRANCOIS a écrit :
> Même en essayant simplement de convertir les fichiers tex :
> 
>   for filename in ` find . -type f -name *.tex`

Tu dois mettre entre quote le pattern:

  for filename in ` find . -type f -name '*.tex'`

-- 
  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B

signature.asc
Description: This is a digitally signed message part


Re: script purge-old-kernels

2017-02-15 Thread Darac Marjal

On Wed, Feb 15, 2017 at 03:30:55PM +, Wolfgang Truber wrote:

Hello,



why is under Debian no possibility to install the script purge-old-kernels or
the package bikeshed (this package includes the script purge-old-kernels).


There appears to be a program called "purge-old-kernels" in the byobu 
package. This may or may not be the program you're looking for.


byobu is described as a "text window manager, shell multiplexer, 
integrated DevOps environment", which may be more than you need for such 
a simple script.


However, there appear to be no outstanding bugs which prevent the 
installation of byobu.


As an alternative to installing all of byobu, you could fetch the 
"purge-old-kernels" script from the upstream repository: 
https://github.com/achernya/byobu/blob/master/usr/bin/purge-old-kernels


(Or have you tried that already? What error did you get?)

--
For more information, please reread.



Re: script purge-old-kernels

2017-02-15 Thread Brad Rogers
On Wed, 15 Feb 2017 15:30:55 +
Wolfgang Truber  wrote:

Hello Wolfgang,

>why is under Debian no possibility to install the script
>purge-old-kernels or the package bikeshed (this package includes the
>script purge-old-kernels).

bikeshed seems to have been superseded by byobu.  That package contains
the purge-old-kernels script.

-- 
 Regards  _
 / )   "The blindingly obvious is
/ _)radnever immediately apparent"
Bet you thought you knew what I was about
Problem - Sex Pistols


pgpAPSV3gfM1q.pgp
Description: OpenPGP digital signature


Re: Script conversió fotografies CR2 a DNG

2016-11-10 Thread Xavi Llista
Hola Andrés,
moltes gràcies per l'explicació detallada. És exactament així.
Salutacions,
Xavi

El dia 4 de novembre de 2016, 22:15, Andrés  ha
escrit:

> Hola llista,
>
> fa molt que no escric aquí ni m'ho miro gaire, menys avui... Crec que
> estàs de sort Xavi :)
>
> Am 04/11/2016 um 15:13 schrieb Narcis Garcia:
> > https://en.wikipedia.org/wiki/Phatch
> >
> > El 04/11/16 a les 14:45, Xavi Llista ha escrit:
> >> fa dies que miro de trobar la manera de crear un script (més o menys
> >> senzill) per convertir de forma massiva tots els fitxers de fotografia
> >> d'una determinada capreta en format CR2 a format DNG. He estat mirant
> >> moltes pàgines però he estat capaç de trobar cap eina que em permeti
> >> executar amb línia de comandes alguna instrucció per convertir els CR2 a
> >> DNG.
>
>
> Doncs mira, justament fa un parell de mesos vaig ocupar-m'hi amb aquests
> temes.
> Resulta que CR2 no és pas "un format" en el sentit que no és una cosa
> estandarditzada. Vol dir que cada fabricant de càmeres fa el que el
> rota. Això vol dir que el format d'un fitxer RAW de la càmera X pot ser
> diferent del fitxer RAW de la càmera Y, encara que siguin del mateix
> fabricant.
>
> Bàsicament l'estat actual de les coses és:
> - Reverse engineering per entendre com funcionen les diferents càmeres
> - Adaptació dels algorismes que interpreten aquests fitxers
>
> Havent fet aquesta introducció, sí que hi ha eines que tracten amb
> aquests fitxers; dcraw [1] és *EL* programa per tractar amb imatges RAW
> però estic bastant segur que només converteix a Bitmap d'algun tipus. Si
> trobes una llibreria per això, molt probablement és un "wrapper"
> respecte aquest programa.
>
> En Narcís mencionava Phatch per convertir entre formats RAW, però crec
> que això no és ben bé el que passa. Mirant les dependències de
> phatch-cli [2], diria que bàsicament fa servir dcraw per llegir les
> imatges RAW i per tant deu fer servir un Bitmap intermig.
>
> Per convertir entre formats RAW no sé de cap programa (lliure) en línia
> de comandes, per la pinta que fa DigiKam 2.7 tenia justament el que
> necessites [3] en un dels programes de 'test' per un plugin. La pregunta
> és si, com crec que fa el Phatch, fa servir un Bitmap intermig!
> La resposta està, és clar, en mirar-se el codi... Per això és programari
> lliure.
>
> En fi, el tema és més complicat del que hom s'espera... Jo et
> recomanaria que si t'interessa mantenir la fidelitat de les teves fotos
> i el format RAW de la teva càmera és suportat per dcraw, no facis cap
> tipus de conversió fins que realment les treballis; de fet hi ha gent a
> la xarxa que comença a desaconsellar convertir a DNG tot plegat [4] [5].
> Si la teva càmera suporta generar fitxers DNG, això seria la
> configuració ideal.
>
> Espero que tota aquesta parrafada et serveixi d'alguna cosa i si
> descobreixes més coses ens avisis :).
>
> Salut,
>
> [1]: http://www.cybercom.net/~dcoffin/dcraw/dcraw_ca.1.html
> [2]: https://packages.debian.org/jessie/phatch-cli
> [3]: https://searchcode.com/codesearch/view/20116600/
> [4]: https://photographylife.com/why-i-no-longer-convert-raw-files-to-dng
> [5]:
> http://petapixel.com/2015/07/16/why-i-stopped-using-the-dng-file-format/
> --
> Andrés
>
>


Re: script inutilisable ( GPT + pas de partition valable ??)

2016-11-07 Thread Pascal Hambourg

Le 07/11/2016 à 16:30, Daniel Caillibaud a écrit :

PG>
PG>   sfdisk -l | awk '/sdf1/ {print $1}'
PG>
PG> Attention : identifiant de table de partitions GPT (GUID) détecté sur
PG> « /dev/sdc ». L'utilitaire fdisk ne prend pas GPT en charge. Utilisez
PG> GNU Parted.

Le pb a été résolu entre temps par les uuid, mais sinon tu avais la réponse 
dans le message
d'erreur, fdisk et sfdisk ne gèrent pas les tables de partitions gpt, il faut 
utiliser parted
ou gdisk.


Les versions récentes de fdisk comme celle de Jessie gèrent le format 
GPT. Visiblement ce message provient d'une vieille version.




Re: script inutilisable ( GPT + pas de partition valable ??)

2016-11-07 Thread Daniel Caillibaud
Le 03/11/16 à 16:34, pat G  a écrit :
PG> Bonjour bernard,
PG> 
PG> il y a encore plus de lignes affichées :
PG> 
PG> #
PG> 
PG>   sfdisk -l | awk '/sdf1/ {print $1}'
PG> 
PG> Attention : identifiant de table de partitions GPT (GUID) détecté sur 
PG> « /dev/sdc ». L'utilitaire fdisk ne prend pas GPT en charge. Utilisez 
PG> GNU Parted.

Le pb a été résolu entre temps par les uuid, mais sinon tu avais la réponse 
dans le message
d'erreur, fdisk et sfdisk ne gèrent pas les tables de partitions gpt, il faut 
utiliser parted
ou gdisk.

-- 
Daniel

I ♥ rien, I'm parisien



Re: Script conversió fotografies CR2 a DNG

2016-11-04 Thread Andrés
Hola llista,

fa molt que no escric aquí ni m'ho miro gaire, menys avui... Crec que
estàs de sort Xavi :)

Am 04/11/2016 um 15:13 schrieb Narcis Garcia:
> https://en.wikipedia.org/wiki/Phatch
> 
> El 04/11/16 a les 14:45, Xavi Llista ha escrit:
>> fa dies que miro de trobar la manera de crear un script (més o menys
>> senzill) per convertir de forma massiva tots els fitxers de fotografia
>> d'una determinada capreta en format CR2 a format DNG. He estat mirant
>> moltes pàgines però he estat capaç de trobar cap eina que em permeti
>> executar amb línia de comandes alguna instrucció per convertir els CR2 a
>> DNG.


Doncs mira, justament fa un parell de mesos vaig ocupar-m'hi amb aquests
temes.
Resulta que CR2 no és pas "un format" en el sentit que no és una cosa
estandarditzada. Vol dir que cada fabricant de càmeres fa el que el
rota. Això vol dir que el format d'un fitxer RAW de la càmera X pot ser
diferent del fitxer RAW de la càmera Y, encara que siguin del mateix
fabricant.

Bàsicament l'estat actual de les coses és:
- Reverse engineering per entendre com funcionen les diferents càmeres
- Adaptació dels algorismes que interpreten aquests fitxers

Havent fet aquesta introducció, sí que hi ha eines que tracten amb
aquests fitxers; dcraw [1] és *EL* programa per tractar amb imatges RAW
però estic bastant segur que només converteix a Bitmap d'algun tipus. Si
trobes una llibreria per això, molt probablement és un "wrapper"
respecte aquest programa.

En Narcís mencionava Phatch per convertir entre formats RAW, però crec
que això no és ben bé el que passa. Mirant les dependències de
phatch-cli [2], diria que bàsicament fa servir dcraw per llegir les
imatges RAW i per tant deu fer servir un Bitmap intermig.

Per convertir entre formats RAW no sé de cap programa (lliure) en línia
de comandes, per la pinta que fa DigiKam 2.7 tenia justament el que
necessites [3] en un dels programes de 'test' per un plugin. La pregunta
és si, com crec que fa el Phatch, fa servir un Bitmap intermig!
La resposta està, és clar, en mirar-se el codi... Per això és programari
lliure.

En fi, el tema és més complicat del que hom s'espera... Jo et
recomanaria que si t'interessa mantenir la fidelitat de les teves fotos
i el format RAW de la teva càmera és suportat per dcraw, no facis cap
tipus de conversió fins que realment les treballis; de fet hi ha gent a
la xarxa que comença a desaconsellar convertir a DNG tot plegat [4] [5].
Si la teva càmera suporta generar fitxers DNG, això seria la
configuració ideal.

Espero que tota aquesta parrafada et serveixi d'alguna cosa i si
descobreixes més coses ens avisis :).

Salut,

[1]: http://www.cybercom.net/~dcoffin/dcraw/dcraw_ca.1.html
[2]: https://packages.debian.org/jessie/phatch-cli
[3]: https://searchcode.com/codesearch/view/20116600/
[4]: https://photographylife.com/why-i-no-longer-convert-raw-files-to-dng
[5]:
http://petapixel.com/2015/07/16/why-i-stopped-using-the-dng-file-format/
-- 
Andrés



Re: Script conversió fotografies CR2 a DNG

2016-11-04 Thread Eloi
El 04/11/16 a les 14:45, Xavi Llista ha escrit:
> Hola,
> fa dies que miro de trobar la manera de crear un script (més o menys
> senzill) per convertir de forma massiva tots els fitxers de fotografia
> d'una determinada capreta en format CR2 a format DNG. He estat mirant
> moltes pàgines però he estat capaç de trobar cap eina que em permeti
> executar amb línia de comandes alguna instrucció per convertir els CR2
> a DNG.
>
> Existeix el conversor que DNGConverter que ve amb el Digikam que em
> permet fer-ho de forma gràfica però no trobo la manera
> d'automatitzar-lo amb un script.
>
> Algú de vosaltres em pot donar un cop de mà?
>
> Moltes gràcies
>
> Xavi
>

No conec cap dels dos formats d'imatge, però pots provar amb
GraphicsMagick o ImageMagick si els suporta. És una eina de consola de
transformació i manipulació d'imatges que es pot automatitzar.



[résolu] Re: script inutilisable ( GPT + pas de partition valable ??)

2016-11-03 Thread pat G
justement j'étais en train de regarder comment on fait pour monter des 
disques avec l'uuid...


du coup ta réponse répond à mon problème

merci :)


Le 03/11/2016 à 15:51, Sébastien NOBILI a écrit :

Bonjour,

Le jeudi 03 novembre 2016 à 14:00, pat G a écrit :

dans un script je veux vérifier la présence d'un disque (et sa première
partition), mais ça indique pleins de choses qui normalement/habituellement
ne s'affichent pas (malgré le grep), du coup mon script ne peut pas
continuer à faire son travail habituel.

À mon tour d’apporter ma façon de procéder. Perso, je regarde si le périphérique
existe en cherchant son UUID dans « /dev/disk/by-uuid/ ».

 if [ -e /dev/disk/by-uuid/... ]; then
 # Ton code ici
 fi

Sébastien





Re: script inutilisable ( GPT + pas de partition valable ??)

2016-11-03 Thread pat G

Bonjour bernard,

il y a encore plus de lignes affichées :

#

 sfdisk -l | awk '/sdf1/ {print $1}'

Attention : identifiant de table de partitions GPT (GUID) détecté sur 
« /dev/sdc ». L'utilitaire fdisk ne prend pas GPT en charge. Utilisez 
GNU Parted.


début : (c,h,s) attendu (0,0,2) trouvé (0,0,1)

Attention : identifiant de table de partitions GPT (GUID) détecté sur 
« /dev/sdb ». L'utilitaire fdisk ne prend pas GPT en charge. Utilisez 
GNU Parted.


début : (c,h,s) attendu (0,0,2) trouvé (0,0,1)

Attention : identifiant de table de partitions GPT (GUID) détecté sur 
« /dev/sdd ». L'utilitaire fdisk ne prend pas GPT en charge. Utilisez 
GNU Parted.


début : (c,h,s) attendu (0,0,2) trouvé (0,0,1)

Attention : identifiant de table de partitions GPT (GUID) détecté sur 
« /dev/sda ». L'utilitaire fdisk ne prend pas GPT en charge. Utilisez 
GNU Parted.


début : (c,h,s) attendu (0,0,2) trouvé (0,0,1)

sfdisk: Erreur : le secteur 0 n'a pas une signature MS-DOS
 /dev/md0 : type non reconnu de table de partition
Aucune partition repérée

sfdisk: Erreur : le secteur 0 n'a pas une signature MS-DOS
 /dev/md1 : type non reconnu de table de partition
Aucune partition repérée

sfdisk: Erreur : le secteur 0 n'a pas une signature MS-DOS
 /dev/md2 : type non reconnu de table de partition
Aucune partition repérée

sfdisk: Erreur : le secteur 0 n'a pas une signature MS-DOS
 /dev/md3 : type non reconnu de table de partition
Aucune partition repérée
/dev/sdf1
#

ça ne m'aide pas pour supprimer les affichages non désiré.

mais merci quand même...


Le 03/11/2016 à 14:27, bernard schoenacker a écrit :

serait il possible de remplacer :
  fdisk -l |grep sdf1 |awk '{print $1}'

  par

  sfdisk -l | awk '/sdf1/ {print $1}'

  slt
  bernard





Re: script inutilisable ( GPT + pas de partition valable ??)

2016-11-03 Thread Sébastien NOBILI
Bonjour,

Le jeudi 03 novembre 2016 à 14:00, pat G a écrit :
> dans un script je veux vérifier la présence d'un disque (et sa première
> partition), mais ça indique pleins de choses qui normalement/habituellement
> ne s'affichent pas (malgré le grep), du coup mon script ne peut pas
> continuer à faire son travail habituel.

À mon tour d’apporter ma façon de procéder. Perso, je regarde si le périphérique
existe en cherchant son UUID dans « /dev/disk/by-uuid/ ».

if [ -e /dev/disk/by-uuid/... ]; then
# Ton code ici
fi

Sébastien



Re: script inutilisable ( GPT + pas de partition valable ??)

2016-11-03 Thread bernard schoenacker
On Thu, 3 Nov 2016 14:00:48 +0100
pat G  wrote:

> Bonjour,
> 
> dans un script je veux vérifier la présence d'un disque (et sa
> première partition), mais ça indique pleins de choses qui 
> normalement/habituellement ne s'affichent pas (malgré le grep), du
> coup mon script ne peut pas continuer à faire son travail habituel.
> 
> ##
> 
> fdisk -l |grep sdf1 |awk '{print $1}'
> 
> Attention : identifiant de table de partitions GPT (GUID) détecté sur 
> « /dev/sdc » ! L'utilitaire sfdisk ne prend pas GPT en charge.
> Utilisez GNU Parted.
> 
> Attention : identifiant de table de partitions GPT (GUID) détecté sur 
> « /dev/sdb » ! L'utilitaire sfdisk ne prend pas GPT en charge.
> Utilisez GNU Parted.
> 
> Attention : identifiant de table de partitions GPT (GUID) détecté sur 
> « /dev/sdd » ! L'utilitaire sfdisk ne prend pas GPT en charge.
> Utilisez GNU Parted.
> 
> Attention : identifiant de table de partitions GPT (GUID) détecté sur 
> « /dev/sda » ! L'utilitaire sfdisk ne prend pas GPT en charge.
> Utilisez GNU Parted.
> 
> Le disque /dev/md0 ne contient pas une table de partitions valable
> Le disque /dev/md1 ne contient pas une table de partitions valable
> Le disque /dev/md2 ne contient pas une table de partitions valable
> Le disque /dev/md3 ne contient pas une table de partitions valable
> /dev/sdf1
> ##
> 
> Quelqu'un saurait ce qui peut provoquer ce bug ? je vois bien une 
> histoire de GPT et le fait que le raid ne contient pas une table de 
> partitions valable, et pourtant...
> 
> lorsque je fais un print all dans parted, ça m'indique ceci :
> 
> ##
> 
>   print all
> Model: ATA WDC WD30EZRX-00D (scsi)
> Disk /dev/sda: 3001GB
> Sector size (logical/physical): 512B/4096B
> Partition Table: gpt
> 
> Number  Start   End SizeFile system Name  Flags
>   1  1049kB  105MB   104MB bios_grub
>   2  105MB   315MB   210MB   ext2  boot
>   3  315MB   3459MB  3145MB  linux-swap(v1)raid
>   4  3459MB  29,7GB  26,2GB  ext4  raid
>   5  29,7GB  55,9GB  26,2GB  ext4  raid
>   6  55,9GB  3001GB  2945GB  ext4  raid
> 
> 
> Model: ATA WDC WD30EZRX-00D (scsi)
> Disk /dev/sdb: 3001GB
> Sector size (logical/physical): 512B/4096B
> Partition Table: gpt
> 
> Number  Start   End SizeFile system Name  Flags
>   2  1049kB  106MB   105MB bios_grub
>   1  106MB   316MB   210MB   ext2  boot
>   3  316MB   3461MB  3146MB  linux-swap(v1)raid
>   4  3461MB  29,7GB  26,2GB  ext4  raid
>   5  29,7GB  55,9GB  26,2GB  ext4  raid
>   6  55,9GB  3001GB  2945GB  ext4  raid
> 
> 
> Model: ATA WDC WD30EZRX-00D (scsi)
> Disk /dev/sdc: 3001GB
> Sector size (logical/physical): 512B/4096B
> Partition Table: gpt
> 
> Number  Start   End SizeFile system Name  Flags
>   1  1049kB  106MB   105MB bios_grub
>   2  106MB   316MB   210MB   ext2  boot
>   3  316MB   3461MB  3146MB  linux-swap(v1)raid
>   4  3461MB  29,7GB  26,2GB  ext4  raid
>   5  29,7GB  55,9GB  26,2GB  ext4  raid
>   6  55,9GB  3001GB  2945GB  ext4  raid
> 
> 
> Model: ATA WDC WD30EZRX-00D (scsi)
> Disk /dev/sdd: 3001GB
> Sector size (logical/physical): 512B/4096B
> Partition Table: gpt
> 
> Number  Start   End SizeFile system Name  Flags
>   1  1049kB  105MB   104MB bios_grub
>   2  105MB   315MB   210MB   ext2  boot
>   3  315MB   3459MB  3145MB  linux-swap(v1)raid
>   4  3459MB  29,7GB  26,2GB  ext4  raid
>   5  29,7GB  55,9GB  26,2GB  ext4  raid
>   6  55,9GB  3001GB  2945GB  ext4  raid
> 
> 
> Model: WD My Book 1170 (scsi)
> Disk /dev/sdf: 3001GB
> Sector size (logical/physical): 4096B/4096B
> Partition Table: msdos
> 
> Number  Start   End SizeType File system  Flags
>   1  1049kB  3001GB  3001GB  primary
> 
> 
> Model: Linux Software RAID Array (md)
> Disk /dev/md0: 9426MB
> Sector size (logical/physical): 512B/4096B
> Partition Table: loop
> 
> Number  Start  End SizeFile system Flags
>   1  0,00B  9426MB  9426MB  linux-swap(v1)
> 
> 
> Model: Linux Software RAID Array (md)
> Disk /dev/md1: 78,6GB
> Sector size (logical/physical): 512B/4096B
> Partition Table: loop
> 
> Number  Start  End SizeFile system  Flags
>   1  0,00B  78,6GB  78,6GB  ext4
> 
> 
> Model: Linux Software RAID Array (md)
> Disk /dev/md2: 78,6GB
> Sector size (logical/physical): 512B/4096B
> Partition Table: loop
> 
> Number  Start  End SizeFile system  Flags
>   1  0,00B  78,6GB  78,6GB  ext4
> 
> 
> Model: Linux Software RAID Array (md)
> Disk /dev/md3: 8834GB
> Sector size (logical/physical): 

Re: script inutilisable ( GPT + pas de partition valable ??)

2016-11-03 Thread Sil

Le 03/11/2016 14:00, pat G a écrit :

Bonjour,
dans un script je veux vérifier la présence d'un disque (et sa 
première partition),

Bonjour,
Perso j'utilise "fdisk -s" dans mes scripts de détection de disques de 
sauvegarde.


Disk="/dev/sdd"
FdiskList="/sbin/fdisk -l ${Disk}"
ResultFdisk=$( ${FdiskCmd} 2>&1 )
if [[ ${ResultFdisk} == "fdisk: cannot open"* ]]
then ...   # Pas de disque dans le lecteur

Sil




Re: script vraag

2016-10-26 Thread mj

Hoi Vincent, lijst,

Bedankt voor je uitleg!

Wat ook werkt:


if test $(find $errorfile -mmin +5); then


Groet,
MJ

On 10/24/2016 04:32 PM, Vincent Zweije wrote:

On Mon, Oct 24, 2016 at 02:04:43PM +0200, mj wrote:

||  Alleen de regels volgend op
||  > if test 'find $errorfile -mmin +30'; then
||  worden TELKENS uitgevoerd, en niet alleen slechts wanneer de $errorfile
||  ouder is dan 30 minuten.

De enkele quotes (') maken dat de string 'find $errorfile -mmin +30'
zonder verdere interpretatie als command line argument aan het test
programma wordt gegeven. Het test programma stelt vast dat dit geen lege
string is, en levert succes op. De then-code wordt dus altijd uitgevoerd.

Zonder veel verder te kijken: misschien bedoel je:

if find $errorfile -mmin +30 >/dev/null; then

Vincent.





  1   2   3   4   5   6   7   8   9   10   >