883 links
  • thican's links | thican.net
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
Links per page: 20 50 100
page 1 / 1
5 results tagged bash x
  • Syntax [Bash Hackers Wiki]
    Un wiki bien documenté sur le fonctionnement de la syntaxe Bash.
    March 2, 2014 at 1:25:41 AM GMT+1 - permalink -
    QRCode
    - http://wiki.bash-hackers.org/syntax/start
    bash GNU software
  • Vidar’s Blog » Why Bash is like that: suid
    Savez-vous que les scripts Bash ne s'exécutent pas s'ils sont le bit SUID d'actif ?
    Comme l'explique cet article, Bash de sa propre initiative perd les droits root, et ceci pour éviter de créer des failles.

    Cela peut paraître évident pourquoi, mais il est étonnant de voir les angles d'attaques possibles pour acquérir les droits root à partir d'un simple script Bash avec le SUID.

    La sécurité est un domaine très vaste.
    January 13, 2014 at 11:25:37 PM GMT+1 - permalink -
    QRCode
    - http://www.vidarholen.net/contents/blog/?p=30
    bash GNU sécurité
  • [GNU/Linux] Sauvegarder des fichiers vers un FTP serveur en ligne de commande.
    Si vous avez besoin de sauvegarder des fichiers, en les mettant sur un serveur ftp distant, tout ça en tâche automatique, voici un script de mon cru (parmi tant d'autres, je n'ai pas cherché) qui peut rendre bien service :

    (EDIT: Vu que les indentations ont sauté, voici une copie directe en téléchargement http://thican.net/~thican/backup-ftp.sh)

    ################################
    #!/bin/env bash
    # coding: utf-8
    # Script for saving files through FTP, to a remote host (for cron or CLI)
    # Thibaud CANALE
    # thican [at] thican [dot] net
    # 2013-06-09
    # GPLv3

    # Parameters for FTP host (you only need to edit this 4 parameters)
    hostFTP="" # "ftp.example.com"
    userFTP="" # "foo"
    passwordFTP="" # "bar"
    remoteDir="./"; # remote directory, where to save files (like "backup")
    # you have to create the directory yourself.

    tempIFS=${IFS};
    IFS=$'\x0a\x00'; # useful to avoid problem with namefiles contening some
    # spaces (sic)
    errorStatue=false;

    # Test if parameters for the connexion to the FTP host are all set.
    if [ "x${hostFTP}" = "x" ] || [ "x${userFTP}" = "x" ] ||
    [ "x${passwordFTP}" = "x" ]; then
    echo "ERROR: at least one parameter for FTP connexion is not set. Exiting." >&2
    exit 1;
    fi

    # Test if at least one parameter is given.
    if [ "x${1}" = "x" ]; then
    echo "Missing arguments. Exiting." >&2
    exit 2;
    fi

    # Check if each ${args} is a regular file, to be upload to ftp server.
    # If yes, uploading it now.
    # If no, display a message error.
    for args in ${@}; do
    if [[ -f ${args} && ! -L ${args} ]]; then # symbolic files are ignored.
    ftp -n ${hostFTP}<<END
    user ${userFTP} ${passwordFTP}
    put ${args} ${remoteDir:-"./"}/$(basename ${args})
    bye
    END
    else
    errorStatue=true;
    echo "${args} is NOT a regular file. Skipping." >&2;
    fi
    done


    #IFS=$'\x20\x09\x0a\x00'; # Reset of the default IFS (I don't care about the old one)
    IFS=${tempIFS};

    # We check if ${errorStatue} containts some error.
    if ${errorStatue}; then
    exit 3;
    fi
    exit 0
    ################################

    Ainsi, sauvegardez donc ce script dans /usr/local/bin/, par exemple, éditez donc les paramètres de connexion au serveur FTP dans le début du script, et utilisez-le avec cron, juste après vos tâches de sauvegardes automatisées.

    Voilà, ce n'était pas plus compliqué que ça. :-)
    June 9, 2013 at 2:09:46 PM GMT+2 - permalink -
    QRCode
    - http://thican.net/~thican/backup-ftp.sh
    astuces bash DIY GNU/Linux informatique logiciel_libre script thican
  • Internal field separator - Wikipedia, the free encyclopedia
    (Note to myself)
    Internal field separator sous GNU/Linux.

    Par défaut :
    % echo -n -E $IFS | hexdump -C --
    00000000  20 09 0a 00                                       | ...|
    00000004

    \x20 == espace, \x09 == tabulation "\t", \x0a == nouvelle ligne "\n" et \x00 == NULL
    https://fr.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange#Table_des_128_caract.C3.A8res_ASCII

    (Je mets toujours du temps à retrouver ça, même si cette fois, c'est arrivé du premier coup, alors je sais qu'ici, je le retrouverai plus rapidement.)
    June 7, 2013 at 12:53:50 PM GMT+2 - permalink -
    QRCode
    - https://en.wikipedia.org/wiki/Internal_field_separator
    astuces bash GNU/Linux programmation script
  • unix - SED: How can I replace a newline (\n)? - Stack Overflow
    Dans la série "les problèmes que j'ai rencontrés, et qu'avoir la solution est bien pratique", je présente le problème du "parse new line" :

    Concrètement, imaginez que vous devez, pour X ou Y raisons, "analyser" (venant de l'anglais "to parse" http://translate.google.fr/translate_t?q=to+parse) les "retours à la ligne" ("new line") pour les modifier en d'autres caractères (comme '\n', textuellement), un simple "sed 's/\n/mon_texte/g'" ne fonctionnera.

    Ainsi, merci à StackOverFlow pour la réponse suivante :
    sed ':a;N;$!ba;s/\n/mon_texte/g' mon_fichier.txt

    Je copie simplement ici l'explication (principalement au cas où le lien meurt) :

    This will read the whole file in a loop, then replaces the newline(s) with a space.
    1. create a label via :a
    2. append the current and next line to the pattern space via N
    3. if we are before the last line, branch to the created label $!ba ($! means not to do it on the last line (as there should be one final newline)).
    4. finally the substitution replaces every newline with a space on the pattern space (which is the whole file).

    Il existe aussi tr :
    tr '\n' ' ' < mon_fichier.txt

    Mais tr ne remplace que par un SEUL caractère ... dommage.

    Pour ceux qui veulent en savoir plus, un commentaire un peu plus bas explique bien mieux http://stackoverflow.com/a/7697604
    February 5, 2013 at 12:03:15 PM GMT+1 - permalink -
    QRCode
    - http://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n
    astuces bash GNU/Linux programmation
Links per page: 20 50 100
page 1 / 1
Shaarli - The personal, minimalist, super-fast, database free, clarity, bookmarking service by the Shaarli community - Help/documentation