writing the value from a file into a table


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting writing the value from a file into a table
# 8  
Old 09-19-2006
hi, PLZ ignore my previous post. I am pasting my full code here. I get the same error as i told earlier. thanks for your help.

Code:
#
# Purpose: - Turn on Workflow Monitor agents that are not in 'running'/'online' state

umask 000
export LT=`date +%Y%m%d_%H%M%S`

if [ -f ./WorkflowMon_env.rc ]
then
   . ./WorkflowMon_env.rc
else
   echo "FATAL: Error sourcing Workflow Server Components!" >> error.log
   exit -1
fi

# Obtain the secure username and password (if it exists)
#
if [ -f "$BATCH_USER_DIR/batch_user.ksh" ]
then
   TMPPWD=`pwd`               
   cd $BATCH_USER_DIR         
   . ./batch_user.ksh        
   RTNCD=$?                 
   cd $TMPPWD              
   if [ $RTNCD = 0 ]
   then
      export SIEBEL_USERNAME=$USERID
      export SIEBEL_PASSWORD=$PASSWORD
   else
      echo "FATAL: batch_user.ksh returned an error ($RTNCD)" >> error.log
      exit -1
   fi
else
   echo "ERROR: batch_user.ksh does not exist, unable to source in variables" >> error.log
   exit -1
fi
export temp_output=$BATCH_USER_DIR/WorkflowMon/log/temp_$LT.out
sqlplus -S n9912499/n9912499@acsblest <<!
CREATE TABLE temp
(status varchar(20),
comp_name varchar(100),
srvr_name varchar(10));
!

x=`echo ${#wfname[*]}<<eof7
eof7`
((x=x+1))
echo $x
i=0

while [ $i -lt ${#wfname[*]} ]
do
         
$SIEBEL_ROOT/bin/srvrmgr -g $SIEBEL_GATEWAY -e $SIEBEL_ENTERPRISE -s $SIEBEL_SERVER -u n9912499 -p n9912499 -c "list component '${wfname[$i]}' show SV_NAME, CC_NAME, CP_DISP_RUN_STATE" -o "$temp_output"  

sed -n "/^SV_NAME/,$ p" < $temp_output | awk '
NR > 2 {n = split($0,arr," ")
printf("%s|",arr[1])
for( i = 2; i <=n-1;++i) printf("%s ",arr[i])
printf("\b|%s\n",arr[n]) }' > temp
old_IFS=$IFS
IFS="|"
while read SV_NAME CC_NAME CP_DISP_RUN_STATE
do
# code for inserting into table
done < temp  <------------ gets an error like this "done unexpected"
IFS=$old_IFS

rm temp

((i=i+1))


done

# 9  
Old 09-19-2006
I am not able to find this in your code
Code:
old_IFS=$IFS
IFS="|"
while read SV_NAME CC_NAME CP_DISP_RUN_STATE
do
# add your code here 
done < temp  
IFS=$old_IFS

rm temp


what i meant was to add code in above while loop to insert into table
# 10  
Old 09-19-2006
can you remove this "# code for inserting into table" and add your original code there?
It wont give error if add your code there buddy
or else add this run the code

Code:
echo $SV_NAME $CC_NAME $CP_DISP_RUN_STATE

# 11  
Old 09-19-2006
Hi Anbu

You are really a genius. I was able to get what i desired. Thanks a lot for your help. If not for you I would have never achieved this.

I have just 1 more question.

The output of $SV_NAME $CC_NAME $CP_DISP_RUN_STATE is as follows

Code:
sble01   ALLTEL Blackberry LM  Running            

1 row returned.

is there a way to delete the 2 lines following the first line.

Thanks a lot once again.
# 12  
Old 09-19-2006
can you show me the code to get the above result?
# 13  
Old 09-19-2006
Hi Anbu

This is the code that got the result I posted

Code:
#!/bin/ksh
#
# Purpose: - Turn on Workflow Monitor agents that are not in 'running'/'online' state

umask 000
export LT=`date +%Y%m%d_%H%M%S`

if [ -f ./WorkflowMon_env.rc ]
then
   . ./WorkflowMon_env.rc
else
   echo "FATAL: Error sourcing Workflow Server Components!" >> error.log
   exit -1
fi

# Obtain the secure username and password (if it exists)
#
if [ -f "$BATCH_USER_DIR/batch_user.ksh" ]
then
   TMPPWD=`pwd`               
   cd $BATCH_USER_DIR         
   . ./batch_user.ksh        
   RTNCD=$?                 
   cd $TMPPWD              
   if [ $RTNCD = 0 ]
   then
      export SIEBEL_USERNAME=$USERID
      export SIEBEL_PASSWORD=$PASSWORD
   else
      echo "FATAL: batch_user.ksh returned an error ($RTNCD)" >> error.log
      exit -1
   fi
else
   echo "ERROR: batch_user.ksh does not exist, unable to source in variables" >> error.log
   exit -1
fi
export temp_output=$BATCH_USER_DIR/WorkflowMon/log/temp_$LT.out
sqlplus -S n9912499/n9912499@acsblest <<!
CREATE TABLE temp
(status varchar(20),
comp_name varchar(100),
srvr_name varchar(10));
!

x=`echo ${#wfname[*]}<<eof7
eof7`
((x=x+1))
echo $x
i=0

while [ $i -lt ${#wfname[*]} ]
do
         
$SIEBEL_ROOT/bin/srvrmgr -g $SIEBEL_GATEWAY -e $SIEBEL_ENTERPRISE -s $SIEBEL_SERVER -u n9912499 -p n9912499 -c "list component '${wfname[$i]}' show SV_NAME, CC_NAME, CP_DISP_RUN_STATE" -o "$temp_output"  
sed -n "/^SV_NAME/,$ p" < $temp_output | awk '
NR > 2 {n = split($0,arr," ")
printf("%s|",arr[1])
for( i = 2; i <=n-1;++i) printf("%s ",arr[i])
printf("\b|%s\n",arr[n]) }' > temp
old_IFS=$IFS
IFS="|"
while read SV_NAME CC_NAME CP_DISP_RUN_STATE
do
echo $SV_NAME $CC_NAME $CP_DISP_RUN_STATE
rm temp

((i=i+1))


done

However $SV_NAME $CC_NAME $CP_DISP_RUN_STATE gives the following result

Code:
sble01|ALLTEL - WebOrders WorkActn |Online
||
1|row |returned.
||

I dont want anything after the first line and also I dont want the square box in the first line. How do I do that.

Thanks
Ragha
# 14  
Old 09-19-2006
show me what you have in this file $temp_output
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Getting Rid of Annoying Bootstrap Table Borders and Wayward Table Lines

Bootstrap is great; but we have had some issues with Bootstrapped <tables> (and legacy <fieldset> elements) showing annoying, wayward lines. I solved that problem today with this simple jQuery in the footer: <script> $(function(){ $('tr, td, fieldset,... (0 Replies)
Discussion started by: Neo
0 Replies

2. Shell Programming and Scripting

Perl: Writing table values to a file

I have a file like this, 1,a,saurav 2,b,rout I want to show this file in a perl cgi page table and want to add a column which will contain a text box. There I will give some manual input, which will be written to the existing file(or a new file) in below format. 1|a|saurav|bangalore... (2 Replies)
Discussion started by: sauravrout
2 Replies

3. Shell Programming and Scripting

Build a table from a list by comparing existing table entries

I am new to this shell scripting.... I have a file which contains list of users. This files get updated when new user comes into the system. I want to create script which will give a table containing unique list of users. When I say unique, it means script should match table while parsing... (3 Replies)
Discussion started by: dchavan1901
3 Replies

4. Shell Programming and Scripting

awk - writing matching pattern to a new file and deleting it from the current file

Hello , I have comma delimited file with over 20 fileds that i need to do some validations on. I have to check if certain fields are null and then write the line containing the null field into a new file and then delete the line from the current file. Can someone tell me how i could go... (2 Replies)
Discussion started by: goddevil
2 Replies

5. UNIX for Dummies Questions & Answers

Writing a script that will take the first line from each file and store it in an output file

Hi, I have 1000 files names data1.txt through data1000.txt inside a folder. I want to write a script that will take each first line from the files and write them as output into a new file. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

6. UNIX for Dummies Questions & Answers

Creating a condensed table from a pre-existing table in putty

Hello, I'm working with putty on Windows 7 professional and I'd like to know if there's a way to gather specific lines from a pre-existing table and make a new table with that information. More specifically, I'd like the program to look at a specific column, say column N, and see if any of the... (5 Replies)
Discussion started by: Deedee393
5 Replies

7. Shell Programming and Scripting

Writing file name and date from LS command into a file to be imported into mysql

I am looking to do a ls on a folder and have the output of the ls be structured so that is is modificaiton date, file name with the date in a format that is compatible with mysql. I am trying to build a table that stores the last modification date of certain files so I can display it on some web... (4 Replies)
Discussion started by: personalt
4 Replies

8. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

9. Shell Programming and Scripting

select values from db1 table and insert into table of DB2

Hi I am having three oracle databases running in three different machine. their ip address is different. from one of the DB am able to access both the databases.(means am able to select values and insert values in to tables individually.) I need to fetch some data from DB1 table(say DB1 ip is... (2 Replies)
Discussion started by: aemunathan
2 Replies

10. Shell Programming and Scripting

help for writing shell script to export table data

Hi All, I need to write a shell script(ksh) to take the tables backup in oracle(exporting tables data). The tables list is not static, and those are selecting through dynamic sql query. Can any body help how to write this shell script. Thanks, (3 Replies)
Discussion started by: sankarg
3 Replies
Login or Register to Ask a Question