![]() |
Ciao e benvenuto da al UNIX e Linux Forum! Grazie per la visita ed unirsi alla nostra Comunità Globale.
|
|
google unix.com
|
|||||||
| Forum | Registrati | Regole Forum | Collegamenti | Album | FAQ | Members List | Calendario | Ricerca | Today's Posts | Mark Forums Read |
| Shell scripting e di programmazione Pubblica domande su KSH, CSH, SH, Bash, Perl, PHP, sed, awk e da altri script di shell e linguaggi di scripting shell qui. |
Più di UNIX e Linux Forum Argomenti potreste trovare utili
|
||||
| Filo | Thread Starter | Forum | Risposte | Ultimo Post |
| Nella lettura dei file | Pablo_beezo | SUN Solaris | 1 | 06-12-2008 11:21 AM |
| Lettura di file | OOP | UNIX for Dummies Domande & Risposte | 3 | 07-31-2007 08:40 AM |
| lettura. bin | eastcoast_uix | UNIX for Dummies Domande & Risposte | 1 | 06-26-2007 02:43 PM |
| lettura file gz | arushunter | Shell scripting e di programmazione | 2 | 02-16-2007 06:29 PM |
| Lettura di file *. chm? | riwa | UNIX for Dummies Domande & Risposte | 3 | 04-02-2006 10:30 PM |
|
|
LinkBack | Thread Tools | Cerca in questo Thread | Rate Thread | Modalità di visualizzazione |
|
||||
|
HELP! Problema nella lettura dei file
HI,
Ho scritto uno script in cui si legge in un file che ha una lista di file all'interno di essa. Lo script quindi ricerche nella directory di questi file e quando si trova in uscita ad una email con un layout tabella che indica la data del file e uno stato ok se il file \u003d data di oggi, se non di attesa appare. (è il destinatario di dimostrare che hanno bisogno di cacciare per il file di attesa). due dei file sono data odierna - jkl.csv e stu.txt il resto sono in bianco o non sia data odierna. Il problema che ho è che non riesco a ottenere l'attesa / ok per lavoro. Lo script che segue è l'output di tutti i file di avvertimento quando in realtà tutti dovrebbero essere di avviso, ad eccezione jkl.csv e stu.txt? lo script è il seguente: #! / bin / ksh ########### # # VARIABILI ########### RUNREF \u003d `date +% Y% m% d` FILE_LIST \u003d"../ parms / files.txt " Subject \u003d "File Check xxx" EMAIL \u003d "cdmspb" MAIL_FROM \u003d "xxx" LOG_DIRECTORY \u003d"../ log " MSG_DEST \u003d "$ (LOG_DIRECTORY) / $ (RUNREF) _build.log" argv0 \u003d `basename $ 0` fsz \u003d 47 ul \u003d"----------------------------------------------- " ck \u003d "+" cs \u003d "|" ########### FUNZIONI # # ########### writelogf () ( if [$ #-gt 9] allora printf "Impossibile generare richieste di errore linea \ n" exit 1 fi args \u003d $ # $ args caso in 1) printf "$ 1"> &2;; 2) printf "$ 1" "$ 2"> &2;; 3) printf "$ 1" "$ 2" "$ 3"> &2;; 4) printf "$ 1" "$ 2" "$ 3" "$ 4"> &2;; 5) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5"> &2;; 6) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5" "$ 6"> &2;; 7) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5" "$ 6" "$ 7"> &2;; 8) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5" "$ 6" "$ 7" "$ 8"> &2;; 9) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5" "$ 6" "$ 7" "$ 8" "$ 9"> &2;; esac $ args caso in 1) printf "$ 1">> $ MSG_DEST; 2) printf "$ 1" "$ 2">> $ MSG_DEST; 3) printf "$ 1" "$ 2" "$ 3">> $ MSG_DEST; 4) printf "$ 1" "$ 2" "$ 3" "$ 4">> $ MSG_DEST; 5) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5">> $ MSG_DEST; 6) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5" "$ 6">> $ MSG_DEST; 7) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5" "$ 6" "$ 7">> $ MSG_DEST; 8) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5" "$ 6" "$ 7" "$ 8">> $ MSG_DEST; 9) printf "$ 1" "$ 2" "$ 3" "$ 4" "$ 5" "$ 6" "$ 7" "$ 8" "$ 9">> $ MSG_DEST; esac ) get_time_stamp () ( ts_time \u003d `date +"% H:% M:% S "` ts_date \u003d `date +"% d% B% Y "` ) start_msg () ( get_time_stamp writelogf "\ n $ MSG di ricerca avviato da $ $ ts_time sulla ts_date \ n \ n" ) end_msg () ( get_time_stamp writelogf "\ n $ MSG ricerca completata da $ $ ts_time sulla ts_date \ n" ) email_user () ( mail-t "$ 1" <<EOF Oggetto: $ 3 Da: $ 2 $ 4 $ 5 EOF ) ############# # # Script principale ############# Status \u003d "OK" MSG \u003d "In attesa di xxx file" PASSO start_msg $ $ MSG writelogf "$ argv0 :+%-${ fsz). $ () fsz s-% - $ () fsz. $ () fsz s-% - fsz $ (). fsz) ($ s + \ n" $ $ ul ul $ ul writelogf "$ argv0 :|%-${ fsz). fsz) ($ s $ (cs }%-${ fsz). fsz) ($ s $ (cs }%-${ fsz). fsz) ($ s cs $ () \ n "" File "" DATA "" Status " writelogf "$ argv0 :|%-${ fsz). fsz) ($ s $ (ck }%-${ fsz). fsz) ($ s $ (ck }%-${ fsz) s | \ n" $ $ $ ul ul ul mentre leggere FILE fare file_date \u003d `ls-l $ FILE | nawk 'BEGIN (FS \u003d" ") (printf"% s% s \ n ", $ 6, $ 7)'` MESE \u003d `date +"% b "| cut-d" "-f1` GIORNO \u003d `date +"% e "| nawk '(printf"% d \ n ", $ 0)'` todays_date \u003d "$ $ MESE GIORNO" if [[( "$ FILE" \u003d\u003d "") | | (! $ FILE-r) | | ($ file_date! \u003d $ todays_date)]] allora Status \u003d "ATTESA" fi # echo "file [$ FILE] [$ Status]" writelogf "$ argv0 :|%-${ fsz). fsz) ($ s $ (cs }%-${ fsz) s $ (cs }%-${ fsz) s $ (cs) \ n" $ FILE " $ file_date "$ Status done <$ FILE_LIST writelogf "$ argv0 :+%-${ fsz). $ () fsz s-% - $ () fsz. $ () fsz s-% - fsz $ (). fsz) ($ s + \ n" $ $ ul ul $ ul PASSO end_msg $ $ MSG # e-mail a tutti gli utenti mailx-r-s $ MAIL_FROM "xxxx File Check" $ email <$ MSG_DEST rm $ MSG_DEST e-mail in uscita è inferiore a: Codice:
Waiting for xxxx files search initiated at 10:55:40 on June 23 2008 test3.sh:+-----------------------------------------------------------------------------------------------------------------------------------------------+ test3.sh:|FILE |DATE |STATUS | test3.sh:|-----------------------------------------------+-----------------------------------------------+-----------------------------------------------| test3.sh:|/abc.txt |Jun 19 |WAITING | test3.sh:|/def.out |Jun 19 |WAITING | test3.sh:|/ghi.dat |Jun 19 |WAITING | test3.sh:|/jkl.csv |Jun 23 |WAITING | test3.sh:|/mno.txt |Jun 11 |WAITING | test3.sh:|/pqr.dat |Jun 11 |WAITING | test3.sh:|/data/stu.txt |Jun 23 |WAITING | test3.sh:|/vw.dat | |WAITING | test3.sh:|/xy.dat | |WAITING | test3.sh:|/z11.dat | |WAITING | test3.sh:+-----------------------------------------------------------------------------------------------------------------------------------------------+ Waiting for xxxxx files search completed at 10:55:41 on June 23 2008 Ultimo a cura di Yogesh Sawant; al 06/23/2008 08:22 AM.. Motivo: aggiunto codice tag |
| Segnalibri |
| Thread Tools | Cerca in questo Thread |
| Modalità di visualizzazione | Vota questo thread |
|
|