![]() |
|
|
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 |
| chmod ricorsivo che riguarda solo le directory? | retrovertigo | UNIX e avanzata per utenti esperti | 1 | 06-22-2007 05:02 PM |
| Sottodirectory pid script | jbarnhar | Shell scripting e di programmazione | 3 | 05-02-2007 04:14 PM |
| Problema con funzione ricorsiva | malle | Shell scripting e di programmazione | 4 | 02-03-2007 10:40 AM |
| directory problema | yeah016 | UNIX for Dummies Domande & Risposte | 2 | 07-22-2006 08:48 AM |
| grep ricorsiva directory | jagannatha | UNIX for Dummies Domande & Risposte | 8 | 07-24-2003 05:00 PM |
|
|
LinkBack | Thread Tools | Cerca in questo Thread | Rate Thread | Modalità di visualizzazione |
|
||||
|
Script problema dovuto alla directory ricorsive Aiuto per favore
Ciao a tutti, sto cercando una soluzione migliore allora quella che ho creato per il mio compito Il compito è: Crea uno script automatizzati che si verifica per Caricamenti in una directory specificata e spostarli in un'altra directory specificata, se i file sono completamente caricato. I file vengono FTP'd alla directory specificata FTPS multipli potrebbe essere in esecuzione in modo sapere se un particolare FTP è completo, è difficile per me, per controllare da ID del processo Ho creato lo script elencati qui sotto, ma può vedere che i problemi possono sorgere con Uploads di Alberi per esempio Se il caricamento ha le seguenti directory: Citazione:
poi dovresti; t che significa che qualsiasi tipo di file e directory sotto al di sotto di tale directory sarà completamente caricato e quindi anche per le vecchie Age che sto cercando? ...... Mi auguro che avevano un senso .... Non credo che se è il caso .... Mi auguro ci sia un modo migliore per affrontare questo problema. Grazie per essere qui. Codice:
#!/bin/bash
#
#
# This script will be used to monitor uploads to a specified directory
# and move them to another directory for downloading.
#
# Things to consider:
# 1. Was the uploaded files uploaded in a sub directory.
# 2. Are the files being uploaded complete.
# 3. Move the files to the specified directory
# with the proper permissions.
#
#
#-------------------------------------------------------------------------------#
#
# Functions
#
#-------------------------------------------------------------------------------#
calc_time() {
AGE_LAST_CHANGED=`expr ${CURRTIME} - ${FILE_LAST_CHANGED}`
if [ ${AGE_LAST_CHANGED} -lt ${ACCEPTED_AGE} ];
then
OK_TO_MOVE=N
else
OK_TO_MOVE=Y
fi
}
check_date() {
FILE_LAST_CHANGED=`stat -t ${NEWFILE} |awk '{print $13}'`
}
#-------------------------------------------------------------------------------#
#
# Vairables will go here
#
#-------------------------------------------------------------------------------#
UPUSER=up_user
DOWNUSER=down_user
#
UPPATH=/home/Private/Uploads
DOWNPATH=/home/Private/Downloads
CURRTIME=`date +%s`
ACCEPTED_AGE=300 # 5 minutes of no activity according to date modified
for f in $( ls ${UPPATH} ); do
if [ -d ${UPPATH}/${f} ];
then
#--- Directory with Subfiles In it ---#
DIR=${UPPATH}/${f}
echo "${DIR} is a Directory"
DIRDATE=`date +%Y_%m_%d_%H%M%S`
NEWDIR=${DOWNPATH}/${f}_${DIRDATE}
NEWFILE=${DIR}
check_date
calc_time
# It appears that the directory has not been changed in the allowed timeframe (ACCEPTED_AGE)
# it is ok to create a new directory in the DOWNPATH now.
# set permissions of new directory to the download user
mkdir ${NEWDIR}
# This causes a problem by leaving the original Directory present in th UPLOADS directory.
for f2 in $(ls ${UPPATH}/$f ); do
NEWFILE=${DIR}/${f2} # Set becuase of check_date function
check_date
calc_time
if [ ${OK_TO_MOVE} = "Y" ];
then
mv ${NEWFILE} ${NEWDIR}
echo "mv ${NEWFILE} ${NEWDIR} "
else
echo "File date is too new to move better wait"
fi
chown -R ${DOWNUSER}:${DOWNUSER} ${NEWDIR}
done
else
#--- File is in Main Upload directory ---#
if [ -f ${UPPATH}/$f ]; then
NEWFILE=${UPPATH}/${f}
echo "${NEWFILE} is a file"
check_date
calc_time
if [ ${OK_TO_MOVE} = "Y" ];
then
mv ${NEWFILE} ${DOWNPATH}
echo "mv ${NEWFILE} ${DOWNPATH} "
chown ${DOWNUSER}:${DOWNUSER} ${DOWNPATH}/*
else
echo "File date is too new to move better wait"
echo "next pass of cronjob should move this file"
fi
fi
fi
done
|
| Segnalibri |
| Thread Tools | Cerca in questo Thread |
| Modalità di visualizzazione | Vota questo thread |
|
|