Suggestions/Recommendations for coding


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Suggestions/Recommendations for coding
# 1  
Old 01-22-2009
Suggestions/Recommendations for coding

Quote:
Guru's, Could you please review my below code i wrote and let me know if you have any recommendations or suggestions for me. I just want to make sure i am not making any major outbreak or silly things while coding, Appreciate your time and help on this. Thanks a lotSmilie
Quote:
First Program to copy/move files and prepare list files
Code:
#!/bin/sh
#set -x
uploaddir="/u01/app/informatica/dev3/sample/GPMDir/UploadDir"
processdir="/u01/app/informatica/dev3/sample/GPMDir/ProcessDir"
datetime=`date +%Y%m%d`
logdir="$processdir/GPMLogFile_$datetime.log"

echo "<---------------Start Copying & Moving GPM Files To Process Directory-------------->" > $logdir

cat /dev/null >$processdir/dummy.txt
echo "Creating A Dummy File In The Process Directory" >> $logdir

rm -rf $processdir/*.list
echo "Removed All The List Files Generated Earlier In The Process Directory" >> $logdir

cd $uploaddir
echo "Current Directory Path Is:" >> $logdir
echo "`pwd`" >> $logdir

if [ -f "$uploaddir"/"GPM_"*".csv" ];then
	cp $uploaddir/GPM_*.csv $processdir
          if [ $? -eq 0 ] ; then
          echo "Master GPM Files Were Copied Successfully Into Process Directory" >> $logdir
          else
	  echo "Error In Copying Master GPM Files Into Process Directory" >> $logdir
          fi
else 
	echo  "Master GPM Files Doesn't Exists In Upload Directory, Hence Cann't Copy Over The Files Into The Process Directory" >> $logdir
fi

if [ -f "$uploaddir"/*"_FI.csv" ]; then
		for i in `ls -rt *_FI.csv`
		do
			echo $processdir/$i>> $processdir/GPM_FI.list
			cp $uploaddir/$i $processdir
			#mv $uploaddir/$i $processdir
		done
	echo "FI Files Exists, Generated The FI File List & Copied Over The FI Files Successfully Into The Process Directory" >> $logdir
else 
	echo "FI Files Doesn't Exists,Creating Dummy File List" >> $logdir
	ls -rt $processdir/dummy.txt > $processdir/GPM_FI.list
fi

Quote:
Second Program To Archive Files
Code:
#!/bin/sh
#set -x
processdir="/u01/app/informatica/dev3/sample/GPMDir/ProcessDir"
archivedir="/u01/app/informatica/dev3/sample/GPMDir/ArchiveDir"
zipfilename="$archivedir"/"GPMArchivedFiles_"`date +%y%m%d`".zip"

echo "<-----------Starting Archiving Of GPM Files For `date +%Y%m%d`-------------->" >> $archivedir/GPMArchive.log

cd $processdir
echo "The Current Directory Path Is:" >> $archivedir/GPMArchive.log
echo "`pwd`" >> $archivedir/GPMArchive.log

for i in `ls -rt *.csv *.log GPM_*.list`
do
echo $i >> $processdir/ArchiveFiles.list
done

while read line
do
zip -mqj $zipfilename $line
if [ $? -eq 0 ];then
echo "$line File Has Been Added To The Zip File $zipfilename"
else
echo "Error In Adding $line To The $zipfilename"
fi
done < $processdir/ArchiveFiles.list

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Conditions/suggestions to use shared library in C/C++ coding

What are the basic conditions to use other people's library in C/C++ coding? Here I do not mean the compiling step, but at the step of writing source code (from scratch in a way!). When using Standard C/C++ Library normally the header (.h/hpp) and corresponding implementation (.c/.cpp) files are... (7 Replies)
Discussion started by: yifangt
7 Replies

2. UNIX for Dummies Questions & Answers

Recommendations on my study path

i have a little background in C (2 sems in university), and have been studying the bash articles on tldp.org i just wanted to know what you guys recommend i look up next. i'm interested in the server administration side of linux, and in kernel and peripheral interface. so i'm not sure whether to... (3 Replies)
Discussion started by: momo.reina
3 Replies

3. UNIX for Dummies Questions & Answers

Reinstall recommendations?

I'm currently running 32-bit Xubuntu 8.10 and I'm thinking of changing over to 64-bit Ubuntu 9.04. Any recommendations on how to make this go more smoothly? -----Post Update----- Can I shuffle around the partitions and install it as a second OS? Is there a good way to do that? (2 Replies)
Discussion started by: CRGreathouse
2 Replies

4. UNIX for Advanced & Expert Users

Request for Recommendations

Hello Guru's, I created this shell script to copy over the files from one location to other location and generating a list of files to process them through ETL tool. Could you please review the code and tell me if you have any recommendations or changes for my code or any thing wrong in my code.... (1 Reply)
Discussion started by: Ariean
1 Replies

5. UNIX for Dummies Questions & Answers

Looking for recommendations for free Xserver

Hello , im not sure if its the right forum... im sorry if not im working with putty allot , but now I started to work with more graphical applications and im looking for free simple and fast Xserver to remote connection, can someone recommend me if there is something like that ? (3 Replies)
Discussion started by: umen
3 Replies

6. Solaris

Swap space recommendations for 9

Core dumps on larger systems have become quite large. Sun, is beginning to ship 146Gig drives. What is the recommended partition size for swap? I can not get a good answer to this question. The double your RAM recommendation is quite old and outdated. thanks (1 Reply)
Discussion started by: bgboost
1 Replies

7. Shell Programming and Scripting

your recommendations

Hi all, I'm trying to teach myself shell programming and scripting. What are good introduction level programming and/or scripting books that you recommend? I will gather your suggestions into a list and check out the IT-related sections of the nearest Barnes & Noble stores. Or if you could... (1 Reply)
Discussion started by: antalexi
1 Replies

8. UNIX for Dummies Questions & Answers

Recommendations for a convert

I'm on my way, I've seen the light and it's not a train at the other end of the tunnel :) What tutorial or manual or reference point(s) would you recommend for an experienced DOS and CP/M type, who wants to learn the command equivalents within Unix? I have a good understanding of program... (2 Replies)
Discussion started by: Keith
2 Replies
Login or Register to Ask a Question