Finding alternative code


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Finding alternative code
# 1  
Old 02-06-2008
Lightbulb Reading environmental variable values

Hi Sir's

I've the below piece of code has the following functionalities:

1) Read the "pcp" file and create Job related parameter file "$PARMFILE".
$PARMFILE has below variables:
AFTD2010 "FILE_TYPE_D=Y export FILE_TYPE_D"
AFTD2010 "FILE_TYPE_I=N export FILE_TYPE_I"
AFTD2010 "FILE_TYPE_S=Y export FILE_TYPE_S"

2) Execute $PARMFILE and remove.

3) Go to the $CTM_FILEDIR location to create temporary files.

4) check for the files type variables $FILE_TYPE_S, $FILE_TYPE_I and $FILE_TYPE_D. If the values for these variables are declared as "Y" then select the appropriate filenames "rubys*_$CTM_ODATE" , "rubyi*_$CTM_ODATE" and "rubyd*_$CTM_ODATE" from the location "$CTM_FTPOUT/" using the command "ls -1".
Condition is, for each file type there should be atleast one file.
example for filenames: "rubys1_20080202", "rubyd8_20080202",
"rubyi22_20080202" etc..

5) Finally I've to put all these file names into single files as "total_arrived_files".

I've written the below code to accomplish this. But are there any other better way to do the same task using "AWK" or "NAWK" by reducing the number of coding lines. ?

##########################################
pcp ${CTM_JOBNAME}$1 $CTM_ODATE > $PARMFILE
. $PARMFILE
rm -f $PARMFILE

cd $CTM_FILEDIR

if [ "$FILE_TYPE_S" == "Y" ]; then
ls -1 $CTM_FTPOUT/rubys*_$CTM_ODATE >> arrived_s_files
if [ $(awk 'END{print NR}' arrived_s_files) -eq "0" ]; then
exit 1
fi
fi

if [ "$FILE_TYPE_I" == "Y" ]; then
ls -1 $CTM_FTPOUT/rubyi*_$CTM_ODATE >> arrived_i_files
if [ $(awk 'END{print NR}' arrived_i_files) -eq "0" ]; then
exit 2
fi
fi

if [ "$FILE_TYPE_D" == "Y" ]; then
ls -1 $CTM_FTPOUT/rubyd*_$CTM_ODATE >> arrived_d_files
if [ $(awk 'END{print NR}' arrived_d_files) -eq "0" ]; then
exit 3
fi
fi

cat arrived_s_files arrived_i_files arrived_d_files > total_arrived_files

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

Thanks in advance / Lokesha

Last edited by Lokesha; 02-07-2008 at 12:17 AM.. Reason: To give the meaningful title
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Challenge in finding listing class method and its number of code lines

there are about 300 objectivec .m files and I need to print each file name and its method and number of lines inside the method there is a sample perl files that do perl brace matching... (0 Replies)
Discussion started by: steve32001
0 Replies

2. Programming

Curl alternative for python code

Need to run this api command via curl, the python code works without any problems , but we want the same to be run as curl command import requests params = {'username': 'testuser'} params = 'c3NhbmthMDJjsd' params = 'test' params = 'guide' params = '192.168.0.37' params =... (2 Replies)
Discussion started by: iron_michael86
2 Replies

3. UNIX for Dummies Questions & Answers

Finding return code for completed process ??

I have Process Id for one background process and currently it is running state. I want to see the return code after the above running process is done. for the forground process normally I use "echo $?". But how to get the return code for my background process on UNIX/Linux?? Thanks in... (5 Replies)
Discussion started by: sriraman2
5 Replies

4. UNIX for Dummies Questions & Answers

Finding implementation code in UNIX for FAT16/32

So we know that Unix is free source software. And we know that Unix have support for FAT 16 and FAT 32. Does anyone know where can I found that implementation in code ? Thank you. (2 Replies)
Discussion started by: medolina
2 Replies

5. Post Here to Contact Site Administrators and Moderators

Alternative button for code tags

I am aware of the many issues surrounding posters not using code tags around code or data. Could we somewhat alleviate this issue by having a better icon that shows more clearly its function? (37 Replies)
Discussion started by: figaro
37 Replies

6. Shell Programming and Scripting

Alternative for wc -l

Hi techies .. This is my first posting hr .. Am facing a serious performance problem in counting the number of lines in the file. The input files i get will be in some 10 to 15 Gb of size or even sometimes more ..and I will load it to db I have used wc -l to confirm whether the loader... (14 Replies)
Discussion started by: rajesh_2383
14 Replies

7. Shell Programming and Scripting

AWK code for finding distances between atoms in two different files

Hi:) I have two separate data files (.xyz) type and I want to see distances between the coordinates of atoms of the two files. For example:- My first files contains 1 1 1 11.50910000 5.17730000 16.49360000 3 1 2 11.21790000 6.36062000 15.60660000 6 1 2 ... (4 Replies)
Discussion started by: ananyob
4 Replies

8. AIX

aix 4.2: finding out the return code of a savevg/mksysb ?

Am I right to assume that to check the return code of a savevg/mksysb on an AIX 4.2 is with the "$?" ? (1 Reply)
Discussion started by: Browser_ice
1 Replies

9. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

10. Solaris

Finding error code

Hi Guys, Can you tell me how to find error code generated by a command. Say i run a command and its generating an error how do i find out its error code ( i know its done using redirection operator.......but not sure how)? (2 Replies)
Discussion started by: nitinkgoud
2 Replies
Login or Register to Ask a Question