Sponsored Content
Top Forums Shell Programming and Scripting Processing multiple files (environment setting) Post 302966993 by captainrhodes on Thursday 18th of February 2016 01:33:54 PM
Old 02-18-2016
Hello Don

Thanks for the reply

Here are the environmental settings we set which will allow the cfxfrwb program to work when processing an individual file:

Code:
ALTORATAB=/cedar/efin/bin/oratab
ANumber=1
ATarget=pre-live
BASEPATH=/usr/sfw/bin:/usr/ccs/bin:/usr/local/bin:/usr/sbin:/usr/bin:/bin
C='\c'
CFXHOME=/cedar/efin/v42/live
CFXSVMODE=2
CFXTAB=/cedar/efin/bin/cfxtab.tab
Choice=1
DEV2K_HOME=/cedar/oracle/Middleware/Oracle_FRHome1
DISPLAY=''
ERRNO=25
FCEDIT=/bin/ed
FORMS_PATH=/cedar/efin/v42/live/lib
FORMS_TERMINAL=/cedar/efin/v42/live/bin
HOME=/export/home/efin
IFS='
'
LC_CTYPE=en_GB.ISO8859-15
LC_MESSAGES=C
LC_MONETARY=en_GB.ISO8859-15
LC_NUMERIC=en_GB.ISO8859-15
LC_TIME=en_GB.ISO8859-15
LD_LIBRARY_PATH=dummy:/cedar/oracle/Middleware/Oracle_FRHome1/lib:/cedar/oracle/Middleware/Oracle_FRHome1/jdk/jre/lib/amd64/native_threads:/cedar/oracle/Middleware/Oracle_FRHome
1/jdk/jre/lib/sparcv9/native_threads:/cedar/oracle/Middleware/Oracle_FRHome1/jdk/jre/lib/sparcv9/server
LINENO=1
LOGNAME=efin
MAIL=/var/mail//efin
MAILCHECK=600
N=''
NLSPATH=dummy:/cedar/efin/v42/live/bin/%N
OLDPS1='[hrbs01efinas]$PWD>'
OLDPWD=/export/home/efin
OPTIND=1
ORACLE_DOC=/cedar/oracle/Middleware/Oracle_FRHome1/odoc
ORACLE_HOME=/cedar/oracle/Middleware/Oracle_FRHome1
ORACLE_INSTANCE=/cedar/oracle/Middleware/asinst_1
ORACLE_SID=EFINL
ORACLE_TERM=vt220
ORATAB=/cedar/efin/bin/oratab
PATH=/cedar/efin/v42/live/bin:/cedar/oracle/Middleware/Oracle_FRHome1/bin:/usr/sfw/bin:/usr/ccs/bin:/usr/local/bin:/usr/sbin:/usr/bin:/bin
PPID=28503
PS1='hrbs01efinas-efin-pre-live>'
PS2='> '
PS3='#? '
PS4='+ '
PWD=/cedar/efin/v42/live
RANDOM=10625
RDBMS_HOME=/cedar/oracle/Middleware/Oracle_FRHome1/
SECONDS=141
SECURITYID=security/security
SHELL=/bin/ksh
SSH_CLIENT='192.168.1.195 55524 22'
SSH_CONNECTION='192.168.1.195 55524 192.168.3.106 22'
SSH_TTY=/dev/pts/2
TERM=xterm
TMOUT=0
TNS_ADMIN=/cedar/oracle/Middleware/asinst_1/config
TWO_TASK=EFINL
TZ=GB
TheChoice=1
USER=efin
_=set


Below is the entire script

Code:
# Script to copy latest efin Reports V403 to a new file for today
  and then transfer them to Datastore
#
# Mar 2013 BM
#
DSDIR=/app/MSS/PROD/print_outs/ds export DSDIR
TODAY=`date '+%b%d'` export TODAY
MONTH=`date '+%b%y'` export MONTH
HOST='192.168.1.22'
USER='xxxxxx'
PASSWD='xxxxx'
#
clear
#
echo "Moving previous EFIN file to /u01/efin/v40/live/report/archive/bon.\n"
#
cd /export/home/efin/efintran/temp
#
mv * /u01/efin/v42/live/report/archive/bon
#
echo ""
#
echo "Done.\n"
#
# Change to home directory /jrie
#
echo "Moving to efin user reports folder \n"
#
cd /u01/efin/v42/live/report/jrie
#
echo "Transfering e-fin reports to temporary folder \n"
#
cp cli_r02*.prt /export/home/efin/efintran/temp
#
cp cli_r04*.prt /export/home/efin/efintran/temp
#
cp act_r07r*.prt /export/home/efin/efintran/temp
#
cp act_r09r*.prt /export/home/efin/efintran/temp
#
cp act_r90r*.prt /export/home/efin/efintran/temp
#
cp act_r92r*.prt /export/home/efin/efintran/temp
#
cp act_r93r*.prt /export/home/efin/efintran/temp
#
cp act_r38r*.prt /export/home/efin/efintran/temp
#
echo ""
#
echo "Done.\n"
#
cd /u01/efin/v42/live/bin
#
echo ""
#
echo "Removing headers from report files \n"
#
#!/bin/bash
FILES=/export/home/efin/efintran/temp/*
for f in $FILES
do
/u01/efin/v42/live/bin/cfxfrwb $f
  echo "Processing $f file..."
  # take action on each file. $f store current file name
done
#
echo "Sticking files together \n"
#
cd /export/home/efin/efintran/temp
#
cat cli_r02*.prt > /export/home/efin/efintran/temp/efinr02$TODAY
#
cat cli_r04*.prt > /export/home/efin/efintran/temp/efinr04$TODAY
#
cat act_r07r*.prt > /export/home/efin/efintran/temp/efin$TODAY
#
cat act_r09r*.prt >> /export/home/efin/efintran/temp/efin$TODAY
#
cat act_r90r*.prt >> /export/home/efin/efintran/temp/efin$TODAY
#
cat act_r92r*.prt >> /export/home/efin/efintran/temp/efin$TODAY
#
cat act_r93r*.prt >> /export/home/efin/efintran/temp/efin$TODAY
#
cat act_r38r*.prt >> /export/home/efin/efintran/temp/efin$TODAY
#
echo "Removing empty spaces from efin files \n"
#
sed '/^$/d' efinr02$TODAY > efinr02a$TODAY
#
sed '/^$/d' efinr04$TODAY > efinr04a$TODAY
#
sed '/^$/d' efin$TODAY > efinall$TODAY
#
rm efinr02$TODAY
#
rm efinr04$TODAY
#
rm efin$TODAY
#
echo "*** Connecting to the DSX Server for file transfer *** \n"
#
ftp -n -v $HOST <<EOF
type ascii
user $USER $PASSWD
cd ..
cd efin
put efinr02*
put efinr04*
put efinall*
bye
/
EOF
#



Basically this script:
goes into a user's directory,
copies some report files to a temp directory,
attempts to process the files using cfxfrwb (which strips out the headers of the report files),
Cats the files together,
FTPs the files over to a document archive device.

As mentioned before , setting the enviroment above will allow cfxfrwb to process an individual report file but it errors when processing a directory full.

Someone mentioned that the #!/bin/bash statement will override the environment settings (I tried removing it and it still errored). I have also tried just setting the enviroment and manually executing
Code:
FILES=/export/home/efin/efintran/temp/*
for f in $FILES
do
/u01/efin/v42/live/bin/cfxfrwb $f
done

still errors.

Many thanks for having a look.
Maybe I'm missing something obvious here..I don't know.

---------- Post updated at 01:33 PM ---------- Previous update was at 01:30 PM ----------

Sorry...I used the wrong code tag...Could a moderator please amend my tags if possible?

Thanks

Last edited by Don Cragun; 02-18-2016 at 06:47 PM.. Reason: Change most ICODE tags to CODE tags.
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Processing Multiple Files

Hello Everyone, I am new to scripting and confused with how to do this efficiently. I am trying to use AWK to do this. I have a lot of files in a folder which has the data of my throughput measurements in two columns i.e. Serial # and Throughput. like this 177.994 847.9 178.996 ... (1 Reply)
Discussion started by: hakim
1 Replies

2. UNIX for Dummies Questions & Answers

Multiple excel files processing on unix

Hi all, I am faced with a rather unusual problem regarding interaction between NT and UNIX. I am using an ETL (Extract-Transform-Load) tool on unix that has the capability to read .xls files. So, when I FTP an excel (.xls) file from a windows server to unix and attempt to read it with this... (3 Replies)
Discussion started by: ucode_2482
3 Replies

3. UNIX for Dummies Questions & Answers

single output of awk script processing multiple files

Helllo UNIX Forum :) Since I am posting on this board, yes, I am new to UNIX! I read a copy of "UNIX made easy" from 1990, which felt like a making a "computer-science time jump" backwards ;) So, basically I have some sort of understanding what the basic concept is. Problem Description:... (6 Replies)
Discussion started by: Kasimir
6 Replies

4. UNIX for Dummies Questions & Answers

Setting up your environment

Hi I am new to Solaris and was just given my id and need to setup my environment, what do i need to do to run certain commands without putting in the complete path. How do I create my .profile, I do not see under my login? Any help would be greatly appreciated. (5 Replies)
Discussion started by: sa_ken
5 Replies

5. Shell Programming and Scripting

multiple groups of files processing

I have five directories, dir1 to dir5 for each directory, I have all same number-named folders. There are four types of folders, {1..10}, {20..30}, { 40..50}, {60..70} Now for each types of folder, I will do the same thing, here is the code for i in {1..5} do cd dir$i mkdir temp1 for... (5 Replies)
Discussion started by: ksgreen
5 Replies

6. Shell Programming and Scripting

Processing multiple files awk

hai i need my single awk script to act on 4 trace files of ns2 and to calculate througput and it should print result from each trace file in a single trace file. i tried with the following code but it doesnt work awk -f awkscript inputfile1 inputfile2 inputfile3 inputfile4>outputfile ... (4 Replies)
Discussion started by: sarathyy
4 Replies

7. Shell Programming and Scripting

Passing multiple files to awk for processing in bash script

Hi, I'm using awk command in bash script. I'm able to pass multiple files to awk for processing.The code i can use is as below(sample code) #!/bin/bash awk -F "," 'BEGIN { ... ... ... }' file1 file2 file3 In the above code i'm passing the file names manually and it is fine till my... (7 Replies)
Discussion started by: shree11
7 Replies

8. Shell Programming and Scripting

Processing multiple files

Hello I have a program cfxfrwb which is designed to remove headers from reports files. The cfxfrwb is located in the following directory /u01/efin/v40/live/bin I run the program against a single report file in the temp directory and it does it's job../cfxfrwb... (2 Replies)
Discussion started by: captainrhodes
2 Replies
All times are GMT -4. The time now is 07:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy