Envoyé par
William Vaurien
et si on veut faire ça depuis le shell lui même (juste pour comprendre) ?
J'ai l'impression que tous programme en shell peut vite devenir un foutoir sans nom.
Rien qu'en lisant le man du bash je me suis rendu compte que je ne connaissais absolu pas la majorités des fonctionnalités.
Et puis je me suis rapidement dit que si je commençais à utiliser ce genre de trucs (par ex ${parameter%%word} et ${parameter##word}, un simple script finirait par ressembler à du perl moisi.
J'ai du réécrire pas mal de vieux shell pour ce projet et je regrette un peu de ne pas être passé directement sur du Python...
Je comprends pas ta question, donc je vais te faire des exemples pour voir si je couvre ton problème
Depuis mon shell (tu voulais dire script peut être ?)
Code:
[root@gorthaur ~]# yum repolist 2>&1 | tee -a testvaurien1
Loaded plugins: product-id, replace, rhnplugin, search-disabled-repos,
: subscription-manager, versionlock
This system is receiving updates from RHN Classic or Red Hat Satellite.
repo id repo name status
!local-rhel7.3-x86_64 Red Hat Enterprise Linux 7.3 - x86_64 4,751
!rapidrecovery rapidrecovery repository 5
!rhel-x86_64-server-7 Red Hat Enterprise Linux Server (v. 7 17,255
!rhel-x86_64-server-extras-7 RHEL Server Extras (v. 7 for 64-bit x 639
!rhel-x86_64-server-optional-7 RHEL Server Optional (v. 7 64-bit x86 12,834
!rhel-x86_64-server-rh-common-7 Red Hat Common (for RHEL 7 Server x86 183
!rhel-x86_64-server-supplementary-7 RHEL Server Supplementary (v. 7 for 6 222
!webtatic/x86_64 Webtatic Repository EL7 - x86_64 444
repolist: 36,333
[root@gorthaur ~]# cat testvaurien1
Loaded plugins: product-id, replace, rhnplugin, search-disabled-repos,
: subscription-manager, versionlock
This system is receiving updates from RHN Classic or Red Hat Satellite.
repo id repo name status
!local-rhel7.3-x86_64 Red Hat Enterprise Linux 7.3 - x86_64 4,751
!rapidrecovery rapidrecovery repository 5
!rhel-x86_64-server-7 Red Hat Enterprise Linux Server (v. 7 17,255
!rhel-x86_64-server-extras-7 RHEL Server Extras (v. 7 for 64-bit x 639
!rhel-x86_64-server-optional-7 RHEL Server Optional (v. 7 64-bit x86 12,834
!rhel-x86_64-server-rh-common-7 Red Hat Common (for RHEL 7 Server x86 183
!rhel-x86_64-server-supplementary-7 RHEL Server Supplementary (v. 7 for 6 222
!webtatic/x86_64 Webtatic Repository EL7 - x86_64 444
repolist: 36,333
Si je veux le faire dans le script, il te faut deux lignes :
Code:
[root@gorthaur ~]# cat myscript.sh
#!/bin/bash
exec 2>&1
exec > >( tee -a vaurien2)
/usr/bin/yum repolist
[root@gorthaur ~]# ./myscript.sh
Loaded plugins: product-id, replace, rhnplugin, search-disabled-repos,
: subscription-manager, versionlock
This system is receiving updates from RHN Classic or Red Hat Satellite.
repo id repo name status
!local-rhel7.3-x86_64 Red Hat Enterprise Linux 7.3 - x86_64 4,751
!rapidrecovery rapidrecovery repository 5
!rhel-x86_64-server-7 Red Hat Enterprise Linux Server (v. 7 17,255
!rhel-x86_64-server-extras-7 RHEL Server Extras (v. 7 for 64-bit x 639
!rhel-x86_64-server-optional-7 RHEL Server Optional (v. 7 64-bit x86 12,834
!rhel-x86_64-server-rh-common-7 Red Hat Common (for RHEL 7 Server x86 183
!rhel-x86_64-server-supplementary-7 RHEL Server Supplementary (v. 7 for 6 222
!webtatic/x86_64 Webtatic Repository EL7 - x86_64 444
repolist: 36,333
[root@gorthaur ~]# cat vaurien2
Loaded plugins: product-id, replace, rhnplugin, search-disabled-repos,
: subscription-manager, versionlock
This system is receiving updates from RHN Classic or Red Hat Satellite.
repo id repo name status
!local-rhel7.3-x86_64 Red Hat Enterprise Linux 7.3 - x86_64 4,751
!rapidrecovery rapidrecovery repository 5
!rhel-x86_64-server-7 Red Hat Enterprise Linux Server (v. 7 17,255
!rhel-x86_64-server-extras-7 RHEL Server Extras (v. 7 for 64-bit x 639
!rhel-x86_64-server-optional-7 RHEL Server Optional (v. 7 64-bit x86 12,834
!rhel-x86_64-server-rh-common-7 Red Hat Common (for RHEL 7 Server x86 183
!rhel-x86_64-server-supplementary-7 RHEL Server Supplementary (v. 7 for 6 222
!webtatic/x86_64 Webtatic Repository EL7 - x86_64 444
repolist: 36,333