While para mover arquivos

1. While para mover arquivos

Marcio Lameira Correa
emlcorrea

(usa Outra)

Enviado em 18/08/2014 - 15:21h

Pessoal, estou com um problema e sou iniciante no shell Script e preciso da valiosa ajuda de vocês.
Meu problema é o seguinte:
No SFTP do servido terá um arquivo .ZIP no zip terá diversos arquivos .txt com a mesma estrutura e nomes diferentes por exempo (FILE_1.txt, FILE_2.txt, FILE_3.txt etc..), preciso move esses arquivos um de cada vez para um diretório específico do servidor onde se ler arquivos de tabela externa.
Como posso fazer um while/for ou etc.. Para ler todos os arquivos um de cada vez?
Os Dados serão inseridos em um tabela de banco de dados, porém cada arquivo deve ser processado individualmente ou seja, quando o shell fizer a chamada do primeiro arquivo e move para diretório em questão, ele deve fazer a chamada do próximo arquivo quando o SQL terminar de processar o primeiro e assim sucessivamente.

Abaixo o shell script.
O código deverá ser inserido a parti das linhas 362.

Se alguem puder ajudar..

#! /bin/bash
. ~/.bashrc
#set -x


### PARAM : $1 -> numberToVerif
function verifNumber()
{
if [ "$(echo ${1} | sed -r 's/[0-9]//g')" != "" ] || [ "${1}" = "" ]
then
return 1
fi
}

sendMail ()
{
mailTo=""
if [ "${processDescription}" = "" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Sending email [ status = OK ]" >> ${logFile}
mailTo="${emailOk}"
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Sending email [ status = KO ]" >> ${logFile}
mailTo="${emailKo}"
fi
cat ${mailFile} | mail -s "$subject" "${mailTo}"
if [ "${?}" = "0" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Email sent" >> ${logFile}
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Email not sent /!\\" >> ${logFile}
fi

}


mailKo ()
{
subject="Error during the process. ${clientNameMaj}"
echo "
Hello,

Here is the synchronisation report on: `date -d '-'${daysAgo}' day' '+%d"/"%m"/"%Y'`

Subject : $clientNameMaj's database synchronisation

---------------------Begining of the report-----------------
------------------------------------------------------------

The file in process is : ${fileToGet}

----------------------- File repport---------------

Error during the process.

--> ${processDescription}

---------------------------------------------------------
-----------------------End of the report-----------------

SmartFocus
http://www.smartfocus.com/"; > ${mailFile}

}


mailOk ()
{
subject="Import: ${clientNameMaj}'s database synchronisation"
echo "
Hello,

Here is the synchronistion report for: `date -d '-'${daysAgo}' day' '+%d/%m/%Y'`

Subject : $clientNameMaj's database synchronisation" > ${mailFile}

echo "

---------------------Begining of rapport-----------------
---------------------------------------------------------

The file in process is : ${fileToGet}

----------------------- File repport---------------

Number of rows in the file: ${nb}

Number of rows with a bad separator: ${ko}
">> ${mailFile}

if [ "${checkSyntax}" = "1" ]
then
echo "
Number of rows with bad email syntax: ${syntaxKo}
" >> ${mailFile}
fi

echo "
------------------------BDD repport -----------------

Number of rows having the correct separator: ${rows}

Number of rows not inserted: ${bad}
- log files on the (s)ftp: synchro/outgoing

Inserted rows: ${rowsInserted}

Updated rows: ${rowsUpdated}" >> ${mailFile}
if [ "${doUnjoin}" = "1" ]
then
echo "
Unsubscribed rows: ${rowsUnjoined}" >> ${mailFile}
fi
echo "

-----------------------End of repport-----------------
------------------------------------------------------

SmartFocus
http://www.smartfocus.com/"; >> ${mailFile}

}


#use : $1 = clientName ; $2 = action ; $3 = Status ; $4 = Raison ; $5 = nb_rows_file ; $6 = nb_ko_rows_file ; $7 = nb_bad_rows_file ; $8 = nb_rows_insert ; $9 = nb_rows_update ; $10 = nb_rows_unjoin
insertMC ()
{
$ORACLE_HOME/bin/sqlplus $db_login/$db_pass@$db_tns << __sql_
insert into datastage_morning_check(JOB_ID,CLIENT_NAME,ACTION, STATUS,nb_rows_file,nb_ko_rows_file,nb_bad_rows_file,nb_rows_insert,nb_rows_update,nb_rows_unjoin,error )
values('${1}_${2}','${1}', '${2}', '${3}','${5}','${6}','${7}','${8}','${9}','${10}','${4}');
commit;
__sql_
}


cleanupDir ()
{
/bin/mkdir ${archivePath}/
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Archive path created" >> ${logFile}

#archive some files
/bin/gzip --best $filePath/*.txt $filePath/*.TXT
/bin/mv $filePath/*.gz $filePath/*.zip ${archivePath}/
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : TXT's file zipped and moved on archive path" >> ${logFile}
/bin/mv $filePath/*.log ${archivePath}/
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : LOG's file moved on archive path" >> ${logFile}

#remove the other
/bin/rm $filePath/*.dat
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : DAT's file removed from data path" >> ${logFile}
/bin/rm $filePath/*.bad
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : BAD's file removed from data path" >> ${logFile}
/bin/rm $filePath/*.ko
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : KO's file removed from data path" >> ${logFile}
/bin/rm ${filePath}*syntax*
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : CHECK SYNTAX temporary file removed from data path" >> ${logFile}
}

daysAgo=0
while getopts "d:" option
do
case ${option} in
d ) daysAgo="${OPTARG}";;
* ) exit 1;;
esac
done
shift $((${OPTIND} - 1))

########################################## I- PARAMETTERS ############################################

clientName="TEST"
country="br"
sep="|"
nbField=30
numberSep=29
clientNameMaj="`echo ${clientName} | tr 'a-z' 'A-Z'`"
emailOk="emlcorreia@alglete.com.br"
emailKo="emlcorreia@alglete.com.br"
filePath="/local00/home/dsadm/${country}/sh_synchro/data/${clientName}/incoming"
scriptsPath="/local00/home/dsadm/${country}/sh_synchro/script/import/${clientName}"
archivePath="${filePath}/archive/$(date -d '-'${daysAgo}' day' '+%Y%m%d')"
logPath="/local00/home/dsadm/${country}/sh_synchro/data/${clientName}/log"
sftp="_sftp"
ftpPath="/local00/ftproot/${clientName}${sftp}/synchro/incoming"
ftpEPath="/local00/ftproot/${clientName}${sftp}/synchro/outgoing"
dynamic_script="/local00/home/dsadm/fr/sh_synchro/script/dynamic_script"
ftpAccess="ftpuser@ftppv"
doUnjoin="1"
emvFTP="1"
ftpServer=""
ftpProtocole=""
ftpDirectory=""
ftpLogin=""
ftpPassword=""

#Please choose your platform:
platform="test"
#platform="podt1"
#platform="podt2"
#platform="podt3"
#platform="podt4"

#load DB parameters, DON'T MODIFY !!!!!!!!!!!!
. /home/dsadm/product/moussexpress/.${platform}_param

case ${platform} in
test)
extFilePath="/data_sync_test"
;;

podt1)
extFilePath="/local01/sync/tab_external"
;;

podt2)
extFilePath="/local01/sync/tab_external/podt2"
;;
podt3)
extFilePath="/local01/sync/tab_external/podt3"
;;
podt4)
extFilePath="/local01/sync/tab_external/podt4"
;;

*)
extFilePath="/data_sync_test"
;;

esac

logFile="${logPath}/${clientName}_import_L$(date +%Y%m%d).log"
processDescription=""


##VARIOUS##
mailFile="${filePath}/${clientName}_mail_report.txt"


verifNumber ${daysAgo}
if [ "$?" != "0" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Parameters (-d) seems wrong" >> ${logFile}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Exiting script" >> ${logFile}
processDescription="Missing parameters"
insertMC "${clientName}" "report" "ERROR" "could not set date to launch" "-1" "-1" "-1" "-1" "-1" "-1"
mailKo
sendMail
cleanupDir
exit 1
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Parameters (-d) seems good" >> ${logFile}
fi


##SQLPLUS##
sqlFileMerge="${scriptsPath}/${clientName}_import_merge_v5.sql"
spoolMergeFile="${filePath}/${clientName}_sql_merge.log"
sqlFileReport="${scriptsPath}/${clientName}_import_report_v5.sql"
reportFile="${filePath}/${clientName}_import_report.dat"

#echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : " >> ${logFile}
######################################################################################################

### Advanced vars ###

#### OPTION CHECKING SYNTAX ####
checkSyntax="1"
separatorCode="124"
syntaxFile="${filePath}/merge_${clientName}_syntax.txt"
syntaxKoFile="${syntaxFile}_syntax.ko"
emailPosition="1"; let emailPosition=($emailPosition-1) #### Count field for email position starts from 0 not 1.
hasHeader="no"
hasHeaderTXT=""
if [ "${hasHeader}" = "1" ]
then
hasHeaderTXT="yes"
else
hasHeaderTXT="no"
fi

#### END CHECKING SYNTAX ####


#### OPTION CRYPTED FILE(S) ####
cryptedFile="0"
cryptedfileName="${clientName}_$(date -d '-'${daysAgo}' day' '+%d%m%Y').TXT"
#### END CRYPTED FILE(S) ####



######################################################################################################


fileToGet="${clientName}_$(date -d '-'${daysAgo}' day' '+%d%m%Y').txt"
fileToSet="${clientName}_$(date -d '-'${daysAgo}' day' '+%d%m%Y').txt"
datFile="sync_${country}_${clientName}_member.dat"
koFile="${clientName}_$(date -d '-'${daysAgo}' day' '+%d%m%Y').txt.ko"


echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : ----------------------------------------------------------------------------" >> ${logFile}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Starting script import" >> ${logFile}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Processing file dated on ==> $(date -d '-'${daysAgo}' day' +'%Y'-'%m'-'%d')" >> ${logFile}

###################################### II- Home directory ##############################################

cd ${filePath}/
if [ "$?" != "0" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Data folder not available" >> ${logFile}
processDescription="Data folder not available"
insertMC "${clientName}" "report" "ERROR" "Data folder not available" "-1" "-1" "-1" "-1" "-1" "-1"
mailKo
sendMail
exit 1
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Data Folder available" >> ${logFile}
fi

#/bin/rm ${sqlLogFile}
/bin/rm ${clientName}*
/bin/rm merge_${clientName}*
/bin/rm -f ${extFilePath}/EXT_MERGE_${clientNameMaj}_*.bad
/bin/rm -f ${extFilePath}/EXT_MERGE_${clientNameMaj}_*.log


##################################### III- FTP get file ##############################################
if [ "${emvFTP}" != "1" ]
then
echo "using external FTP"
#use : $1 => clientName ; $2 => protocole ; $3 => server ; $4 => directory ; $5 => fileToGet ; $6 => fileToSet ; $7 => country ; $8 => login ; $9 => password
${scriptsPath}/${clientName}_external_ftp_sftp_get.sh "${clientName}" "${ftpProtocole}" "${ftpServer}" "${ftpDirectory}" "${fileToGet}" "${fileToSet}" "${country}" "${ftpLogin}" "${ftpPassword}"
if [ "$?" != "0" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Could not get client file [client's (s)ftp]" >> ${logFile}
processDescription="No file found on client's ftp/sftp"
insertMC "${clientName}" "report" "ERROR" "No data file" "-1" "-1" "-1" "-1" "-1" "-1"
mailKo
sendMail
cleanupDir
exit 1
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Could get client file successfully" >> ${logFile}
fi

else
scp "${ftpAccess}:${ftpPath}/${fileToGet}" "${filePath}/${fileToSet}"
if [ "$?" != "0" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Could not get client file" >> ${logFile}
processDescription="No file found on ftp/sftp"
insertMC "${clientName}" "report" "ERROR" "No data file" "-1" "-1" "-1" "-1" "-1" "-1"
mailKo
sendMail
cleanupDir
exit 1
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Could get client file successfully" >> ${logFile}
fi
fi
sleep 5



if [ "${cryptedFile}" = "1" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Starting decryption" >> ${logFile}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Renaming file before decryption" >> ${logFile}
/bin/mv ${filePath}/${fileToSet} ${filePath}/${cryptedfileName}
gpg --no-tty --batch --always-trust --output ${fileToSet} --decrypt ${cryptedfileName}
if [ "$?" != "0" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Could not decrypt file" >> ${logFile}
processDescription="Could not decrypt file"
insertMC "${clientName}" "report" "ERROR" "Error during decryption" "-1" "-1" "-1" "-1" "-1" "-1"
mailKo
sendMail
cleanupDir
exit 1
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Decryption ended successfully" >> ${logFile}
fi

fi



############################################# IV- CLEAN FILE ###############################################

echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Converting file to unix format" >> ${logFile}
/usr/bin/dos2unix ${fileToSet}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Convertion done" >> ${logFile}

#########-------------------------------- Count the separator -----------------------------------#########

echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Checking separators" >> ${logFile}
${dynamic_script}/dynamic_remove_incorrect_rows_separator.pl "${fileToSet}" "${numberSep}" "${sep}"
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Separators checked" >> ${logFile}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Moving file to ${fileToSet}.dat" >> ${logFile}
/bin/mv "${fileToSet}.dat" "${datFile}"

##########################################################################################################
## ##
## ##
## PUT HERE FUTURE FILE's VERIFICATION ##
## ##
## ##
##########################################################################################################

##########------------------------------- CHECK EMAIL SYNTAX -----------------------------------##########

if [ "${checkSyntax}" = "1" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Checking emails syntax" >> ${logFile}
/bin/mv ${datFile} ${syntaxFile}
${dynamic_script}/email_syntax_check_param_integration_V1.pl "${syntaxFile}" "${hasHeaderTXT}" "${datFile}" "${separatorCode}" "${emailPosition}"
syntaxKo="$(wc -l ${syntaxKoFile} | awk -F' ' '{print $1}')"
if [ "${syntaxKo}" = "" ]
then
syntaxKo=0
else
let syntaxKo=(${syntaxKo}-1)
fi
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Checking emails syntax done" >> ${logFile}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Nb of rejected records : ${syntaxKo}" >> ${logFile}
fi
##########----------------------------- END CHECK EMAIL SYNTAX ---------------------------------##########

##########################################################################################################
## ##
## ##
## ##
## DESCRIPTION OF STATISTICS VARIABLES ##
## ##
## nb : nb records on client's file ##
## ko : nb records rejected (bad separator) ##
## rows : nb records to insert on merge table ##
## ##
## ##
##########################################################################################################

ko=`wc -l ${koFile} | awk -F' ' '{print $1}'`
if [ "${ko}" == "" ]
then
ko=0
fi
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : ${ko} row(s) with bad separators" >> ${logFile}


rows=`wc -l "${datFile}" | awk -F' ' '{print $1}'`
if [ "${rows}" == "" ]
then
rows=0
fi
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : ${rows} row(s) with good separators" >> ${logFile}


nb=`wc -l "${fileToSet}" | awk -F' ' '{print $1}'`
if [ "${nb}" == "" ]
then
nb=0
fi
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : ${nb} row(s) on client file" >> ${logFile}



if [ $rows -lt 1 ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : client file is empty" >> ${logFile}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : exiting script" >> ${logFile}
processDescription="File empty after verifications (check separators, syntax, etc.)"
insertMC "${clientName}" "report" "ERROR" "Empty file" "-1" "-1" "-1" "-1" "-1" "-1"
mailKo
sendMail
cleanupDir
exit 1
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Client file has more than one line" >> ${logFile}
fi

############################################### PREPARE MERGE ####################################################

#move the DAT file in "/local01/sync/tab_external" before processing the MERGE
/bin/mv ${filePath}"/"${datFile} ${extFilePath}"/"${datFile}
if [ "$?" != "0" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Could move the file to the tab_external folder" >> ${logFile}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : exiting script..." >> ${logFile}
processDescription="Error while processing [ could not move the file ]"
insertMC "${clientName}" "report" "ERROR" "Could not move the file to the tab_external folder" "-1" "-1" "-1" "-1" "-1" "-1"
mailKo
sendMail
cleanupDir
exit 1
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Move file to tab_external folder successfully" >> ${logFile}
fi

##################################### MERGING INTO TABLE MERGE_[CLIENT]_MEMBER #####################################

echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Merging table merge with client table" >> ${logFile}
${ORACLE_HOME}/bin/sqlplus $db_login/$db_pass@$db_tns << __sql_
whenever sqlerror exit 1
set serveroutput on
spool ${spoolMergeFile}
@${sqlFileMerge}
spool off
quit
__sql_
if [ "$?" != "0" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Could not merge data on client table" >> ${logFile}
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : exiting script..." >> ${logFile}
processDescription="Error while processing [ could not merge data ]"
insertMC "${clientName}" "report" "ERROR" "Could not merge data on client table" "-1" "-1" "-1" "-1" "-1" "-1"
mailKo
sendMail
cleanupDir
exit 1
else
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Merge done successfully" >> ${logFile}
fi




############################################ REPORTING ########################################################
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Starting reporting" >> ${logFile}
${ORACLE_HOME}/bin/sqlplus $db_login/$db_pass@$db_tns << __sql_
@${sqlFileReport}
quit
__sql_
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Reporting get :" >> ${logFile}
#count the number of ros rejected within the merge:

#badFile=`ls -ltrh ${extFilePath}/EXT_MERGE_${clientNameMaj}_*.bad | cut -d' ' -f9 | tail -1`
badFile=`ls ${extFilePath}/EXT_MERGE_${clientNameMaj}_*.bad`
logLoadFile=`ls ${extFilePath}/EXT_MERGE_${clientNameMaj}_*.log`
bad=`wc -l "${badFile}" | awk -F' ' '{print $1}'`
#bad=`wc -l ${badFile}`
if [ "${bad}" == "" ]
then
bad=0
fi
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : ${bad} bad row(s)" >> ${logFile}


rowsInserted=`cat ${reportFile} | cut -d"|" -f1`
rowsUpdated=`cat ${reportFile} | cut -d"|" -f2`
rowsUnjoined=`cat ${reportFile} | cut -d"|" -f3`

if [ "${rowsInserted}" = "" ]
then
rowsInserted=0
fi
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Inserteds rows = ${rowsInserted}" >> ${logFile}

if [ "${rowsUpdated}" = "" ]
then
rowsUpdated=0
fi
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Updated rows = ${rowsUpdated}" >> ${logFile}

if [ "${rowsUnjoined}" = "" ]
then
rowsUnjoined=0
fi
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Unjoined rows = ${rowsUnjoined}" >> ${logFile}

############################################## Get stats ####################################################



${ORACLE_HOME}/bin/sqlplus $db_login/$db_pass@$db_tns << __sql_
set serveroutput on
exec pk_dsadm.calstat('${clientName}_MEMBER');
quit
__sql_


#use : $1 = clientName ; $2 = action ; $3 = Status ; $4 = Raison ; $5 = nb_rows_file ; $6 = nb_ko_rows_file ; $7 = nb_bad_rows_file ; $8 = nb_rows_insert ; $9 = nb_rows_update ; $10 = nb_rows_unjoin
insertMC "${clientName}" "report" "OK" "" "${nb}" "${ko}" "${bad}" "${rowsInserted}" "${rowsUpdated}" "${rowsUnjoined}"
mailOk
sendMail


######################################## PUT HERE SCP COMMAND FOR (S)FTP ######################################

echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Exporting report's file on outgoing directory [(S)FTP]" >> ${logFile}
scp ${badFile} "${ftpAccess}:${ftpEPath}/"
scp ${ctlLogFile} "${ftpAccess}:${ftpEPath}/"
scp ${koFile} "${ftpAccess}:${ftpEPath}/"
if [ "${checkSyntax}" = "1" ]
then
scp ${syntaxKoFile} "${ftpAccess}:${ftpEPath}/"
fi

############################################## VI- REMOVE CLIENT FILE FROM (S)FTP #########################################

if [ "${platform}" != "test" ]
then
if [ "${emvFTP}" = "1" ]
then
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Remove client file from (S)FTP" >> ${logFile}
ssh -l dsadm ${ftpAccess} "rm ${ftpPath}/${fileToGet}"
fi
fi

#################################################################################################################

cleanupDir
echo "L $(date +%Y"-"%m"-"%d" "%H":"%M":"%S) : Script finished successfully. [ END ]" >> ${logFile}
exit 0



  


2. Re: While para mover arquivos

Carlos Adean
c4rl

(usa CentOS)

Enviado em 18/08/2014 - 15:43h

veja se ajuda:


for i in *
do
echo $i
done



Onde está o * você pode colocar o path para arquivos específicos tal como no exemplo abaixo.


for i in /tmp/*.log
do
echo $i
done







Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts