IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Shell et commandes GNU Discussion :

Résultat de la commande grep dans un script shell


Sujet :

Shell et commandes GNU

  1. #1
    Membre régulier
    Homme Profil pro
    Analyste d'exploitation
    Inscrit en
    Juin 2019
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Analyste d'exploitation
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2019
    Messages : 7
    Par défaut Résultat de la commande grep dans un script shell
    Bonjour à tous,
    Le but est de recuperer la date d'expiration d'un certificat web
    1- Je commence par reccuperer l'entete de la page html que je place dans un fichier
    2- Ensuite je filtre cette entete pour en reccuperer la ligne expire date
    3- Je refiltre pour trouver la date
    ......

    sur le 2- j'ai un soucis car il me trouve bien la date mais il m'affiche aussi pleins d'autres informations (voir ci-dessous)
    Comment faire pour les enlever? Ces informations correspondent au fichiers presents dans le repertoire ou il y a le script
    Merci par avance
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    #!/bin/bash
    curl --proxy http://xxxx:xxxxxxx@xxxxxxxxxxxxx:80 https://www.google.fr --verbose --head >/temp/certif_0207.txt  2>&1
    filt1=$(grep "expire date:" /temp/certif_0207.txt)
     
    echo "=================================================="
    echo $filt1

    Resultat commande grep

    0 alerte-virus-sophos_postes a.out authfile.json balancer-manager balancer-manager.1 bornes certif_html.sh check_accesslog_ip.sh check_aix_errpt.sh check_aix_process2.pl check_aix_process.pl check_aix_swap check_aix_swap_french check_alfresco check_alfresco_debug check_alfresco.jar check_apt check_as400 check_asm check_bdd_request.pl check_bp_status.pl check_breeze check_by_ssh check_cas-1.4.pl check_cas14.pl check_cas-bis-bis.pl check_cas-bis.pl check_cas-new.pl check_cas.pl check_cas_v3.pl check-cisco.pl check_cisco_snmp.pl check_clamd check_cluster check_cluster_win.pl checkcpl.py check_curl_http_EPARTENAIRE-integ.php check_curl_http_EPARTENAIRE.php check_curl_http_EPARTENAIRE-prod.php check_curl_http.php check_curl_http_STR_NOTFOUND-avec-arg.php check_curl_http_STR_NOTFOUND.php check_curl_http-v11.php check_datacore.sh check_dbi check_dd.pl check_dell_bladechassis check_dell_openmanage.1.3.pl check_dell_powerconnect check_delta.sh check_dhcp check_dig check_dirsize11.sh check_disk check_disk_smb check_disks_snmp.pl check_dns checkdostrk.py check_ds35xx.pl check_dummy check_emc_clariion_2.pl check_emc_clariion.pl check_emc_trespass.ksh check_equallogic.sh check_FCBrocade_hardware.sh check_file_age check_fileage.py check_file_ages_in_dirs check_file_count check_file_count.php check_file_count_today check_flexlm check_flexlm.plx check_fping check_fsc.pl check_ftp check_hmc.sh check_hp check_hpasm check_hp_bladechassis check_hpjd check_http check_http_proxy check_hwinfo.pl check_ibm_bladecenter.py check_icmp check_ide_smart check_ifoperstatus check_ifstatus check_ilo2_health.pl check_ilo_health.pl check_imap check_int_traffic.pl check_ipmi_sensor_v2.sh check_ircd check_jabber check_javamelody_http.sh check_jboss.pl check_jmx check_jmx-1.2.3 check_jmx.jar check_KB_Status.sh check_ldap check_ldaps check_load check_log check_logfiles check_logfiles-3.6.2.1.tar check_mailq check_mountpoints.sh check_mrtg check_mrtgtraf check_mscs_hpma check_mssql check_mssql_health check_mssql_health.bak check_mssql_health-laurent check_mssql_health_new check_mssql_health.sav check_mssql_job check_mssql_job_history.py check_mysql check_mysql_bytes.pl check_mysql_connections check_mysqld.pl check_mysqld.pl.sav check_mysql_health check_mysql.pl check_mysql_queries.pl check_mysql_query check_mysql_slow.pl check_mysql_threads.pl check_naf.py check_naf.pyc check_naf.pyo check_nagios check_nagiosPerf.sh check_netapp_cluster.pl check_netapp-du check_nntp check_nntps check_nrpe check_nt check_ntp check_ntp_peer check_ntp_server_sync.sh check_ntp_time check_nwc_health check_nwstat check_openmanage check_openmanage-old check_oracle check_oracle_adrci.sh check_oracle_count check_oracle_errorlogs.pl check_oracle_health check_oracle_locks.sh check_oracle_nbLocks.sh check_oracle_sql.pl check_oracle_tablespace.sh check_overcr check_owa.php check_pgsql check_ping check_pop check_port.pl check_postgres.pl check_postgres-test.pl check_powerconnect check_proc_mem.sh check_procs check_proxy_lb_https.sh check_proxy_lb.sh check_proxy.sh check_radius check_real check_rpc check_sensors check_simap check_smtp check_snmp check_snmp_boostedge.pl check_snmp_brocade.pl check_snmp_cisco_stack.pl check_snmp_cisco_traffic check_snmp_cpfw.pl check_snmp_css_main.pl check_snmp_css.pl check_snmp_dell_poweredge check_snmp_env.pl check_snmp_hpux_process.sh check_snmp_IBM_Bladecenter.pl check_snmp_int check_snmp_int.pl check_snmp_linkproof_nhr.pl check_snmp_load.pl check_snmp_mem.pl check_snmp_mem.pl.ori check_snmp_mem.pl.sav check_snmp_netint.pl check_snmp_nsbox.pl check_snmp_powerconnect check_snmp_process check_snmp_process2.pl check_snmp_process.pl check_snmp_storage check_snmp_storage2.pl check_snmp_storage-bis-old.pl check_snmp_storage-bis.pl check_snmp_storage.pl check_snmp_ups.sh check_snmp_uptime.pl check_snmp_uptime.sh check_snmp_vrrp.pl check_snmp_win.pl check_spop check_sqljob.sh check_ssh check_ssl_certificate check_ssmtp checksubs.py check_swap check_switch.pl check_systime_perfdata.pl check_systime.pl check_systime.pl.sav check_tcp check_time check_tina.pl check_tomcatSessions check_traffic.pl checktrk.py check_udp check_ups check_ups_alarms.pl check_ups_health.pl check_ups_mode.pl check_uptime check_uptime_sup-32j.sh check_users check_vmware_api.pl check_vmware_api.pl.sav check_vmware_esx.pl check_vmware.pl check_vmware_snapshots.pl check_vnxe.sh check_wave check_xenapi.pl check_xtream.pl compare_dates conf_check_logfiles.cfg conf_check_logfiles.cfg.sav conf_check_logfiles_mssql.cfg conf_check_logfiles_mysql_centralise.cfg conf_check_logfiles_mysql.cfg conf_check_logfiles_mysql_S01APP002.cfg conf_check_logfiles_oracle_centralise.cfg conf_check_messages.cfg corps_generique_mail.txt DBD demontage-cifs-manuel Downtime eon_mysqlcentral---.php eon_mysqlcentral.php eon_mysqlcentral.php.20160331 evenement.php evenement.php.1 eventhandlers exemple-convert-date.pl Extraopts.pm index.html index.html.1 index.html.2 index.html.3 index.html.4 index.html.5 index.html.6 index.html.7 interne IsiLog jmxquery.jar libnpcommon.a login log-vip mail_cr_eon.sh modules monitoringplugin.py monitoringplugin.pyc monitoringplugin.pyo nagios_alerte_virus nagios_host_mail nagios-jmx-plugin-1.2.3 nagios_perfs.sh nagios_service_mail NAS negate nohup.out nrpe nrpe.cfg nrpe.xinetd nsca nsca.cfg Oracle oraclealertlog.cfg PHPMailer ping_borne ping_ip pnp4n_send_host_mail.pl pnp4n_send_service_mail.pl port.sh README README.md rep serveurcentral.mysql sessions-e01esx202p sessions-e01esx901p simplivity-backup.py simplivity-hard.py simplivity-host-state.py simplivity-replication.py snmpwalk_l01sup001p snmpwalk_l03ged007p snmpwalk_l06sup002p snmpwalk_sinagios80 snnpwalk.txt sqljdbc.jar SqlJobMon.class sqlnet.log ssl StartAll.do?environnement=epartenaire.integration.toulouse-metropole.fr StartAll.do?environnement=epartenaire.integration.toulouse-metropole.fr.1 StartAll.do?environnement=epartenaire.integration.toulouse-metropole.fr.2 StartAll.do?environnement=epartenaire.integration.toulouse-metropole.fr.3 StartAll.do?environnement=epartenaire.integration.toulouse-metropole.fr.4 StartAll.do?environnement=epartenaire.integration.toulouse-metropole.fr.5 tableau.sh telephonieCPL.py test_alerte test_presence_fich test_presence_fich_NEWVERS test_qtree test_qtree_delib_cutm test_qtree_delib_ville test_qtrees test_taille_qtree toto
    urlize url.properties utils-check_file_ages_in_dirs.sh utils.php utils.pm utils.sh Windows expire date: Sep 03 12:21:00 2019 GMT

  2. #2
    Expert confirmé Avatar de Flodelarab
    Homme Profil pro
    Inscrit en
    Septembre 2005
    Messages
    5 283
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Charente (Poitou Charente)

    Informations forums :
    Inscription : Septembre 2005
    Messages : 5 283
    Par défaut
    Bonjour

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    filt1=$(sed -n '/expire date:/s/.*expire date: //p;' /temp/certif_0207.txt)
    NB: les conduites (pipes) ont justement été créées pour éviter les fichiers temporaires du style "certif_0207.txt".

    Code bash : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $ curl https://www.google.fr --verbose --head 2>&1 | sed -n '/expire date:/s/.*expire date: //p;'
    Sep 10 08:15:00 2019 GMT

  3. #3
    Membre régulier
    Homme Profil pro
    Analyste d'exploitation
    Inscrit en
    Juin 2019
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Analyste d'exploitation
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2019
    Messages : 7
    Par défaut
    Tt d'abord merci pour la réactivité.
    Ensuite avez vous une version 2 justement pour eviter les fichiers temporaires?

  4. #4
    Expert confirmé Avatar de Flodelarab
    Homme Profil pro
    Inscrit en
    Septembre 2005
    Messages
    5 283
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Charente (Poitou Charente)

    Informations forums :
    Inscription : Septembre 2005
    Messages : 5 283
    Par défaut
    Posts croisés, j'imagine. La réponse est déjà au dessus.

  5. #5
    Membre régulier
    Homme Profil pro
    Analyste d'exploitation
    Inscrit en
    Juin 2019
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Analyste d'exploitation
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2019
    Messages : 7
    Par défaut
    effectivement. Que dire de plus que merci encore.
    Du coup je clôture
    Bonne journée

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 20
    Dernier message: 30/06/2017, 15h54
  2. Exécuter une commande sudo dans un script shell
    Par lodacom dans le forum Shell et commandes GNU
    Réponses: 11
    Dernier message: 24/04/2014, 13h37
  3. Chercher dans le résultat d'une commande (grep)
    Par Invité dans le forum Langage
    Réponses: 2
    Dernier message: 12/11/2011, 13h23
  4. Execution d'une commande telnet dans un script sh
    Par Nospher dans le forum Linux
    Réponses: 17
    Dernier message: 23/08/2011, 15h30
  5. Lancer une commande Perl dans un script Shell
    Par Ryo_san dans le forum Shell et commandes GNU
    Réponses: 2
    Dernier message: 02/06/2008, 11h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo