Bonjour à tous
Bon je débute en Korn Shell et j'ai un batch a faire au taf dont voici le code :
Code :
- case $1 in
- -g)
- #Connect to FTP server where user files are
- #Only files with ".xls" extension and beginning by "KPI_" prefix are downloaded (see mget pattern)
- print "****************************"
- print "* Recovering XLS files *"
- print "****************************"
- ftp -n -i $FTP_HOST << END_SCRIPT
- user $FTP_USER $FTP_PASSWD
- cd $FTP_USER_DIR
- mget KPI_*.xls
- bye
- END_SCRIPT
- for file in `ls *.xls`
- do
- mv ./$file $LOCAL_PROCESS_DIR
- done
- #Files are copied from process directory to archive directory (we need to keep a log of which files have been processed).
- print "************************"
- print "* XLS files backup *"
- print "************************"
- for file in `ls $LOCAL_PROCESS_DIR/*.xls`
- do
- print "Archiving $file\n"
- cp $file $LOCAL_ARCHIVE_DIR
- done
-
- #Excel files are converted in CSV files
- print "*** Launch XLS to CSV conversion ***\n"
- for file in `ls $LOCAL_PROCESS_DIR/*.xls`
- do
- print "Converting $file\n"
- $LOCAL_SCRIPT_DIR/xls2csv.pl $file
- done
-
- #The first file in the directory is parsed in order to know which KPI it contains
- if file=$(ls $LOCAL_PROCESS_DIR | head -1 | grep METAL); then
- mv $LOCAL_PROCESS_DIR/$file $LOCAL_PROCESS_DIR/KPI_METAL.CSV
- elif file=$(ls | head -1 | grep CORPORATE); then
- mv $LOCAL_PROCESS_DIR/$file $LOCAL_PROCESS_DIR/KPI_CORPORATE.CSV
- elif file=$(ls | head -1 | grep CORF13_KPI1); then
- mv $LOCAL_PROCESS_DIR/$file $LOCAL_PROCESS_DIR/KPI_CORF13_KPI1.CSV
- elif file=$(ls | head -1 | grep CORF13_KPI2); then
- mv $LOCAL_PROCESS_DIR/$file $LOCAL_PROCESS_DIR/KPI_CORF13_KPI2.CSV
- elif file=$(ls | head -1 | grep BUDGET_CORF3_KPI1); then
- mv $LOCAL_PROCESS_DIR/$file $LOCAL_PROCESS_DIR/KPI_BUDGET_CORF3_KPI1.CSV
- elif file=$(ls | head -1 | grep BUDGET_CORF3_KPI2); then
- mv $LOCAL_PROCESS_DIR/$file $LOCAL_PROCESS_DIR/KPI_BUDGET_CORF3_KPI2.CSV
- fi
-
- #We delete all the Excel files in the process directory and keep only CSV ones
- for file in `ls $LOCAL_PROCESS_DIR/*.xls`
- do
- print "Deleting $file\n"
- rm $file
- done
- ;;
- -d)
- rm $LOCAL_PROCESS_DIR/KPI_METAL.CSV
- rm $LOCAL_PROCESS_DIR/KPI_CORPORATE.CSV
- rm $LOCAL_PROCESS_DIR/KPI_CORF13_KPI1.CSV
- rm $LOCAL_PROCESS_DIR/KPI_CORF13_KPI2.CSV
- rm $LOCAL_PROCESS_DIR/KPI_BUDGET_CORF3_KPI1.CSV
- rm $LOCAL_PROCESS_DIR/KPI_BUDGET_CORF3_KPI2.CSV
- ;;
- *)
- echo "Use option -g (get files and convert it to CSV) or -d (delete processed file)"
- ;;
- esac
|
Le problème c est que j'ai l'erreur suivante à l'execution : ./getKPI.sh[15]: syntax error at line 24 : `<<' unmatched
Chose bizarre quand je sors le morceau de code lié à la connexion ftp du case et ben j'ai pas cette erreur tout marche nikel
Si quelqu'un pouvait m'éclairer
Merci bcp
Message édité par Oreste le 21-12-2005 à 14:49:57