Character to be escaped | Escape Sequence | Remark |
% | %% | |
^ | ^^ | May not always be required in doublequoted strings, but it won’t hurt |
& | ^& | |
< | ^< | |
> | ^> | |
| | ^| | |
‘ | ^’ | Required only in the FOR /F « subject » (i.e. between the parenthesis), unless backq is used |
` | ^` | Required only in the FOR /F « subject » (i.e. between the parenthesis), if backq is used |
, | ^, | Required only in the FOR /F « subject » (i.e. between the parenthesis), even in doublequoted strings |
; | ^; | |
= | ^= | |
( | ^( | |
) | ^) | |
! | ^^! | Required only when delayed variable expansion is active |
« | « » | Required only inside the search pattern of FIND |
\ | \\ | Required only inside the regex pattern of FINDSTR |
[ | \[ | |
] | \] | |
« | \ » | |
. | \. | |
* | \* | |
? | \? |
Purge de fichiers FORFILES chemins UNC
set w_dir=%1
set w_nb_jrs=%2
echo Purge de la Directorie : %w_dir%
echo Purge des fichiers et dossiers vieux de plus de %w_nb_jrs% jours
echo Espace avant purge
dir %w_dir%..
pushd %w_dir%
dir
echo « ———————————————–«
FORFILES /S /D -%w_nb_jrs% /C « cmd /c dir @path » 2> nul
set erreurcode=%errorlevel%
if « %erreurcode% » equ « 0 » goto SUITE1
goto FIN
:SUITE1
forfiles /S /D -%w_nb_jrs% /C « cmd /c del /f /q @path » 2> nul
forfiles /S /D -%w_nb_jrs% /C « cmd /c rd /S /Q @path » 2> nul
echo « Effacement des dossiers et fichiers ci-dessus »
echo Espace après purge
dir
:FIN
PopD
set errorlevel=0
Dossier vide sous windows
setlocal ENABLEDELAYEDEXPANSION
set dossier =%1
set /A P1=0
for /R %dossier% %%i in (.) do (if « %%~zi » geq « 1 » ( set /A P1=!P1!+1 ))
if !P1! equ 0 (echo « Le dossier « %dossier% » est vide » && exit /B 0)
accent avec robocopy
Lorsque le chemin vers un répertoire source ou destination de votre script robocopy contient un accent, il est possible, selon la configuration de votre système Windows, que vous obteniez une erreur. En effet DOS n’arrivera pas à interpréter cet accent et ne va donc pas trouver le chemin du répertoire spécifié …
Afin que les accents soient correctement interprétés il suffit de rajouter la commande suivante au début de votre script.
chcp 1252
La commande chcp, intégrée nativement à Windows, permet de modifier le jeu de caractère (ou « code page ») de votre système d’exploitation. Le code page 1252 est le code page original de Windows, pour l’Europe de l’ouest et donc la France. Il peut arriver que le code page d’un système ne soit pas 1252 et que les accents soient donc mal interprétés.
En ajoutant cette commande en début de script, vous améliorerez leur portabilité afin qu’ils fonctionnent sur n’importe quel ordinateur ayant un code page différent.
lftp : pb de certificat
Fatal error: Certificate verification: Not trusted
Ajouter : set ssl:verify-certificate no
dans le fichier /etc/lftp.conf
ou
/.lftprc qui n’impactera que votre utilisateur (pas testé)
Date du dernier redémarrage de Windows
Dans une fenêtre de commande.
Ici c’est le 25 août 2002 à 1h02
C:\Users\ADMSE_EFougere>net statistics workstation
Workstation Statistics for \WCTSRV0054
Statistics since 8/25/2020 1:02:53 AM
Bytes received 2918507
Server Message Blocks (SMBs) received 543
Bytes transmitted 2164838
Server Message Blocks (SMBs) transmitted 0
Read operations 936
Write operations 2
Raw reads denied 0
Raw writes denied 0
Network errors 0
Connections made 0
Reconnections made 0
Server disconnects
Sessions started 0
Hung sessions 0
Failed sessions 0
Failed operations 0
Use count 247
Failed use count 0
The command completed successfully.
C:\Users\ADMSE_EFougere>
Pb zabbix
En ligne de commande sur le serveur zabbix : root@wctsrv0010:/usr/local/bin# zabbix_get -p 10050 -k agent.version -s wctsrv0041
zabbix_get [1536]: Check access restrictions in Zabbix agent configuration
Sur l’inteface web :
Received empty response from Zabbix Agent at [10.129.20.53]. Assuming that agent dropped connection because of access permissions
Server=emea_zabbix.wabtec.com
Pb KTP
De ce que je comprends, le fichier à traiter doit être un fichier .lis dans \\fanny.faiveleytransport.local\splora\o816\fic
le fichier .txt (avec le même nom) dans \\eve.faiveleytransport.local\services\Treso\KTP\Paiements_Qualiac_a_emettre sert pour déclencher le traitement Vtom.
donc j’ai renommé toto.txt en toto.lis \\fanny.faiveleytransport.local\splora\o816\fic
et j’ai copier le fichier toto.txt dans \\eve.faiveleytransport.local\services\Treso\KTP\Paiements_Qualiac_a_emettre Le traitement s’est déclenché.
Pb Email multi destinataires dans les alarmes
vtaddalarm /Name=nom_alarme /Property=action.email.to= »test1@test.com;test2@test.com«
vtaddalarm /Name=Mail_FANNY /Property=action.email.to= »maryline.laboudigue@wabtec.com\;nathalie.ruiz@wabtec.com\;christine.lelannier@wabtec.com »
Solarwinds – Manage add group




Solarwinds – add node





Start agent Vtom remote
Créer une alarme pour détecter sue l’agent est tombé.
Monter une clé ssh entre wctsrv0011 (Vtom serveur) et le poste client à redémarrer (vldtb04x) pour ne pas avoir à saisir le pwd.
Exécuter le script (qui doit se trouver sur le poste client Vtom) : ssh root@vldtb04x « sh /exploit/scripts/vtom_start_vtom_zabbix.sh »
cat /exploit/scripts/vtom_start_vtom_zabbix.sh #!/bin/bash # Start agent Vtom . /opt/vtom/admin/vtom_init.ksh /opt/vtom/admin/start_client ps fax |grep bdaemon # Start agent zabbix sh /etc/init.d/zabbix_agent_start.sh #ps fax | grep zabbix
Remplacement de WM_CONCAT par LISTAGG
SELECT mess_val_col1, WM_CONCAT(mepj_fichier_nom) fichiers, mess_pers_initiale resp_envoi, mess_dt_envoi envoi FROM MESSAGE, message_pieces_jointes WHERE mess_id = mepj_mess_id(+) GROUP BY mess_val_col1, mess_syta_code, mess_pers_initiale, mess_dt_envoi
SELECT mess_val_col1, fichier, mess_pers_initiale resp_envoi, mess_dt_envoi envoi FROM MESSAGE, (SELECT mepj_mess_id, LISTAGG(mepj_fichier_nom, ', ') WITHIN GROUP (ORDER BY mepj_mess_id) AS fichiers FROM MESSAGE_PIECES_JOINTES GROUP BY mepj_mess_id) WHERE mess_id = mepj_mess_id(+) GROUP BY mess_val_col1 ,mess_syta_code ,mess_pers_initiale ,mess_dt_envoi ,fichiers
Ubuntu 18.04 – Écran inversé sur un HP Pavilion
Mémo pour corriger le problème d’écran inversé sur un HP Pavilion (17-g172nf)
En installant Ubuntu 18.04, l’écran s’est brusquement inversé.
A priori, ce serait causé par l’accéléromètre qui est censé protéger le
disque dur à plateau en cas de chute en relevant les têtes de lecture
des disques avant l’impact.
Seulement dans mon cas, j’ai installé un SSD. Donc plus besoin de charger le module hp_accell.
Terminer tant bien que mal l’installation en mode la tête à l’envers et rebooter à la fin de l’installation.
Au premier démarrage, lancer le terminal puis la commande suivante : Shell command sudo modprobe -r hp_accel
sudo modprobe -r hp_accel |
Puis désactiver le chargement au démarrage.
Ajouter cette ligne dans le fichier /etc/modprobe.d/blacklist.conf :
Shell
blacklist hp_accel
blacklist hp_accel |
Terminer la francisation du système
sudo apt install language-pack-fr language-pack-fr-base language-pack-gnome-fr language-pack-gnome-fr-base manpages-fr manpages-fr-extra
Upgrade Ubuntu 17.20 vers 18.04
— upgrade 17.10 vers 18.04.3 LTS
cat /etc/apt/sources.list
cat /etc/issue
uname -a
echo "${XDG_CURRENT_DESKTOP}"
find /etc/apt -name '*.list' -exec bash -c 'echo -e "\n$1\n"; nl -ba "$1"' _ '{}' \;
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get update
sudo apt install -f
dpkg --get-selections | grep 'hold$'
find /etc/apt -type f -name '*.list*' -exec bash -c 'echo -e "\n$1\n"; nl -ba "$1"' _ '{}' \;
sudo do-release-upgrade
La procédure est assez longue, patience.
Partage samba sous Ubuntu
Installer le package cifs-utils
sudo apt-get install cifs-utils
Créer les volumes :
cd /media
sudo mkdir ds_photo ds_videos ds_donnees ds_scan
Créer un fichier /root/.smbcredentials contenant :
username=eric password=le_mot_de passe_du_compte_nas domain=DISKSTATION.local
Dans le fichier /etc/fstab ajouter les lignes suivantes à la fin du fichier :
Bien respecter la casse, remplacer les ‘espaces’ pas ‘\040’
//DISKSTATION.local/photo /media/ds_photo cifs _netdev,credentials=/root/.smbcredentials,auto 0 0
//DISKSTATION.local/Videos /media/ds_videos cifs _netdev,credentials=/root/.smbcredentials,auto 0 0
//DISKSTATION.local/Données\040rangées /media/ds_donnees cifs _netdev,credentials=/root/.smbcredentials,auto 0 0
//DISKSTATION.local/scan /media/ds_scan cifs _netdev,credentials=/root/.smbcredentials,auto 0 0
Lancer la commande mount -a pour monter les partages, ensuite ils se monteront automatiquement au démarrage.
Bascule TTY ou Graphique
Pour basculer sur un autre TTY (CTRL+ALT+F2)
Pour basculer sur la session graphique (CTRL+ALT+F7)
Mot de passe en sortie de veille
gsettings set org.gnome.desktop.lockdown disable-lock-screen 'true' gsettings get org.gnome.desktop.lockdown disable-lock-screen service lightdm restart ou service lightdm stop service lightdm start Bascule mode Terminal / Graphique
Clé d’authentification entre wctsrv0134 et wctsrv0135
Laisser les valeurs par défaut
Sur wctsrv0011
cd /root/.ssh/ root@wctsrv0134:/exploit/scripts# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): [entrée] LAISSER LA VALEUR PAR DEFAUT Enter passphrase (empty for no passphrase): [entrée] Enter same passphrase again: [entrée] Your identification has been saved in /root/.ssh/id_rsa_vtom_main. Your public key has been saved in /root/.ssh/id_rsa_vtom_main.pub. The key fingerprint is: SHA256:c29bbI+32cezIzf97+W75tGjinKSBOjpEW3W1rPRF68 root@wctsrv0011 The key's randomart image is: +---[RSA 2048]----+ | | | . | | o . . . o | | o = o + . . . | | . = o S = . . | | + . + . E .| | . . . . o +++| | . + … =.X@| | +. .o.*X^| +----[SHA256]-----+
root@wctsrv0134:/exploit/scripts# cd /root/.ssh/ root@wctsrv0134:~/.ssh# ll total 32 drwx------ 2 root root 4096 Oct 4 14:00 ./ drwx------ 8 root root 4096 Oct 4 11:33 ../ -rw------- 1 root root 0 Feb 12 2019 authorized_keys -rw------- 1 root root 668 Oct 4 11:39 id_dsa -rw------- 1 root root 605 Oct 4 11:39 id_dsa.pub -rw------- 1 root root 1675 Oct 4 14:00 id_rsa -rw-r----- 1 root root 397 Oct 4 14:00 id_rsa.pub -rw-r--r-- 1 root root 5096 May 15 13:31 known_hosts root@wctsrv0134:~/.ssh# cp id_rsa.pub /home/vtom/.ssh/ root@wctsrv0134:~/.ssh# cd /home/vtom/.ssh/ root@wctsrv0134:/home/vtom/.ssh# ll total 32 drwx------ 2 vtom vtom 4096 Oct 4 14:19 ./ drwxr-x--x 11 vtom vtom 4096 Sep 10 16:47 ../ rw------- 1 vtom vtom 397 May 15 16:08 authorized_keys -rw------- 1 vtom vtom 668 Oct 4 14:02 id_dsa -rw------- 1 vtom vtom 1679 May 15 16:01 id_rsa -rw-r----- 1 vtom vtom 397 May 15 16:01 id_rsa.pub -rw-r----- 1 root root 397 Oct 4 14:19 id_rsa.pub -rw-r--r-- 1 vtom vtom 3540 May 17 07:53 known_hosts
root@wctsrv0134:/home/vtom/.ssh# chown vtom:vtom id_rsa.pub root@wctsrv0134:/home/vtom/.ssh# chmod 600 id_rsa.pub root@wctsrv0134:/home/vtom/.ssh# ll total 32 drwx------ 2 vtom vtom 4096 Oct 4 14:19 ./ drwxr-x--x 11 vtom vtom 4096 Sep 10 16:47 ../ -rw------- 1 vtom vtom 397 May 15 16:08 authorized_keys -rw------- 1 vtom vtom 668 Oct 4 14:02 id_dsa -rw------- 1 vtom vtom 1679 May 15 16:01 id_rsa -rw-r----- 1 vtom vtom 397 May 15 16:01 id_rsa.pub -rw------- 1 vtom vtom 397 Oct 4 14:19 id_rsa.pub -rw-r--r-- 1 vtom vtom 3540 May 17 07:53 known_hosts
root@wctsrv0134:~/.ssh# su - vtom vtom@wctsrv0134:~/.ssh# cd /home/vtom/.ssh/ vtom@wctsrv0134~$ ssh-copy-id -f -i id_rsa.pub wctsrv0135 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_rsa.pub" WARNING: Unauthorized access to this system is forbidden and will be prosecuted by law. By accessing this system, you agree that your actions may be monitored if unauthorized usage is suspected. Ubuntu 18.04.1 LTS Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'wctsrv0135'" and check to make sure that only the key(s) you wanted were added.
vtom@wctsrv0134:~$ ssh wctsrv0135
WARNING: Unauthorized access to this system is forbidden and will be
prosecuted by law. By accessing this system, you agree that your actions
may be monitored if unauthorized usage is suspected.
Ubuntu 18.04.1 LTS
vtom@wctsrv0135:~$
—–> OK
sources : https://www.microlinux.fr/cle-ssh/
Copier le fichier id_rsa.pub sur les autres serveurs pour une authentification sans pwd.
cd /home/vtom/.ssh
ssh-copy-id -f -i id_rsa.pub wctsrv0055
ssh-copy-id -f -i id_rsa.pub wctsrv0056
ssh-copy-id -f -i id_rsa.pub wctsrv0060
… etc…