The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
read files from folder and then call another script girishnn Shell Programming and Scripting 3 11-06-2007 02:53 PM
Help!! Need script to read files and add values by lines... dhuertas Shell Programming and Scripting 3 09-15-2007 08:14 PM
help writing script to read files names technett Shell Programming and Scripting 2 04-26-2005 01:24 PM
help with cshell script to read 1 or more lex files homerj546 Shell Programming and Scripting 1 04-18-2004 07:01 AM
Script with read/write Files steiner Shell Programming and Scripting 5 07-25-2003 07:46 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-31-2008
Registered User
 

Join Date: Dec 2007
Posts: 1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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
Reply With Quote
Google UNIX.COM
Forum Sponsor
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 07:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102