Visit Our UNIX and Linux User Community

Top Forums UNIX for Dummies Questions & Answers How to read the content of the files in unix script Post 302163353 by thila on Thursday 31st of January 2008 10:00:49 PM
Old 02-01-2008
How to read the content of the files in unix script

Hi I need help below is my textfile format look like
PO Nbr Ln Item Number Description Qty Order Order Date Due Date Status Reply ID Reply Date Reply Qty

P304802 1 K0220040 TSX-3225 C 16.367900 MHz 320379 07/01/2008 29/01/2008 REQ OP304802 02/02/2008 190000

P304802 2 K0220040 TSX-3225 C 16.367900 MHz 0 07/01/2008 29/01/2008 REQ OP304802 04/02/2008 130379



I need to check in my unix script
(a) each POnbr must be unique
(b) one POnbr must be one Item Number
(c) the Qty Order must be tally with Reply Qty

and below is my unix script

set DATE=`date '+%y%m%d%H%M%S'`

#set mfgdb="crp3"
set mfgdb="prod"
set file="TMREPLY"
set epmhome="/home/int/${mfgdb}/oed"
set datfile="etth009.csv"

#set shellhome="/u4/home/it/itjob/batch"
#set shellname="bat_crp3"
set shellhome="/u4/home/it/itjob/batch"
set shellname="bat_prod"

set stat=0

echo "------------------------------------"
date

### file check (receive) ###
echo "### Check error file exist ###"
file ${epmhome}/receive/${datfile}*
set stat=${status}

if (${stat} != 0) then
echo "No Error File Found at Receive"
else
echo "Error File Found at Receive"
goto END_OF_PROCESS
echo "OK: `date '+%T'`"
endif

RECEIVE_LOOP:

### File check at receive folder ###
echo "### File check at receive ###"
file ${epmhome}/receive/${file}*
set stat=${status}
if ({$stat} != 0) then
echo "OK: `date '+%T'`"
echo "No Data at Receive folder"
goto NOMAL_END
endif
echo "OK: `date '+%T'`"

echo "### Check error file exist ###"
file ${epmhome}/receive/${datfile}*
set stat=${status}

if (${stat} != 0) then
echo "No Error File Found at Receive"
else
echo "Error File Found at Receive"
goto END_OF_PROCESS
echo "Error File Found: `date '+%T'`"
endif

### filename get ###
echo "### File load ###"
cd ${epmhome}/receive
set getfile=`ls ${file}* | head -1`
#set loadfile=`echo $getfile:r`
#echo "loadfilename="${loadfile}

### Copy File to archive ###
echo "### Copy file to archive folder ###"
cp ${epmhome}/receive/${getfile} ${epmhome}/archive/

### Send out email ###
echo "### Send e mail ###"
uuencode ${epmhome}/receive/${getfile} ${getfile}| mailx -s ETTH_REPLY_Data twloh@epsontoyocom.com


### Change File Name ###
echo "### Move File name to etth009.csv ###"
mv ${epmhome}/receive/${getfile} ${epmhome}/receive/${datfile}
set stat=${status}
if ({$stat} != 0) then
echo "Move ERROR"
goto END_OF_PROCESS
endif
echo "OK: `date '+%T'`"

### MFG/Pro CIM load process ###
echo "### Reply format CIM Load ###"
${shellhome}/${shellname} "ETTH2"

set stat=${status}
if (${stat} != 0) then
echo "MFG/Prod Load Error"
goto END_OF_PROCESS
endif
echo "OK: `date '+%T'`"

echo "----------- RECEVE_LOOP ------------"

goto RECEIVE_LOOP

### Nomal End ###
NOMAL_END:
echo "### Nomal End ###"
set stat=0
echo "*-----------------------------------"
exit {$stat}

### End of process ###
END_OF_PROCESS:
set stat=1
echo "#-----------------------------------"
exit {$stat}

Please help me to check the validation in the unix script
 
Test Your Knowledge in Computers #348
Difficulty: Easy
Awk's built-in variables include the field variables: $1, $2, $3, and so on ($0 represents the entire record).
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

file read + unix script

hi, how can i read line by line from a file using unix shalle script? Thanks and Regards Vivek.S (2 Replies)
Discussion started by: vivekshankar
2 Replies

2. Shell Programming and Scripting

Can I use read to read content of a variable

Can I use the read command to read the contents of a variable? I'm trying by using the following code and getting nothing back. I'm in a Linux environment. #!/bin/ksh IFS=~ VAR1=1~2~3~4 echo $VAR1 | read a b c d print "$a $b $c $d" (9 Replies)
Discussion started by: nmalencia
9 Replies

3. Shell Programming and Scripting

Unix script to segregate dynamic and static content of a web application

I need to deploy a JAVA application on two separate servers: 1. Web server (IBM HTTP Web Servers (IHS)) 2. Application Server (WebSphere Application Server WAS7.0) The static content will have to be deployed and handled on Web server. These would include GIFs, HTML, CSS, etc files.... (0 Replies)
Discussion started by: chani27
0 Replies

4. Shell Programming and Scripting

Need to build Shell Script to search content of a text file into a folder consist several files

Have to read one file say sourcefile containing several words and having another folder containing several files. Now read the first word of Sourcefile & search it into the folder consisting sevral files, and create another file with result. We hhave to pick the filename of the file in which... (3 Replies)
Discussion started by: mukesh.baranwal
3 Replies

5. UNIX for Dummies Questions & Answers

Read all files in a directory for a unix command

Hello, Below, I have a unix command, which can be executable for single file. cat input.txt | sort -k3,3 > output.txt I have 100 input files in a directory. It is hectic and time taking to run the above command for all the 100 files for 100 times. Now, I want to execute the above unix... (2 Replies)
Discussion started by: koneru_18
2 Replies

6. Shell Programming and Scripting

Read files in shell script code and run a C program on those files

HI, I am trying to implement a simple shell script program that does not make use of ls or find commands as they are quite expensive on very large sets of files. So, I am trying to generate the file list myself. What I am trying to do is this: 1. Generate a file name using shell script, for... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

7. Shell Programming and Scripting

How to read a two files, line by line in UNIX script and how to assign shell variable to awk ..?

Input are file and file1 file contains store.bal product.bal category.bal admin.bal file1 contains flip.store.bal ::FFFF:BADC:CD28,::FFFF:558E:11C5,6,8,2,1,::FFFF:81C8:CA8B,::FFFF:BADC:CD28,1,0,0,0,::FFFF:81C8:11C5,2,1,0,0,::FFFF:81DC:3111,1,0,1,0 store.bal.... (2 Replies)
Discussion started by: veeruasu
2 Replies

8. Shell Programming and Scripting

Perl SCript to read file content (if else statemenet)

Hi All, I wanted to write a perl script to read the content in a file,the file content is either 0 (zero) OR 1. The idea is like this. If (content =1), then it will proceed to perform some step. and then update the file content to 0(zero) else if (content =0), it will update the content to... (11 Replies)
Discussion started by: hploh
11 Replies

9. UNIX for Beginners Questions & Answers

Linux read specific content file from tar.gz files without extracting

hello i wish to write the result of these below conditions in a file: 1. in a specific folder, i have many tar.gz files. 2. each tar.gz file contains ".dat" file in sub folders. 3. i wish to get the full path of these .dat files, if i find in it a specific word ("ERROR24"). 4. all this... (6 Replies)
Discussion started by: jimmyjames9
6 Replies

10. UNIX for Beginners Questions & Answers

How to read multiple files at same time through UNIX scripting?

How to read multiple files at simultaneously? (1 Reply)
Discussion started by: Priyanka_M
1 Replies

Featured Tech Videos

All times are GMT -4. The time now is 08:27 AM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy