ksh program


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh program
# 1  
Old 01-09-2012
ksh program

Hi,
I have a text file with multiple sql statements in which I have pick only the below select update and delete statements and do print as given below.
All the select,update,delete statements will be as same as ( subquery with ().all statements ending with ; ) the examples given below.

Code:
1) select some text 
 (select some text(select some text) 
 where some condition) 
where condition;
 
2)update some text where condition;
 
3)delete some text where condition;

For all the select,update and delete statements there should be corresponding "where" clause.
In 1st example all the select has it's corresponding where clause.
except one select statement inside(sub query) dose not have its where clause. in this case we should print out as "no where clause".

In 2nd input, an update statement should have a where clause.
If update statement does not have it then we should print out "no where clause".

Same as update for delete.

Last edited by methyl; 01-09-2012 at 09:10 AM.. Reason: correct accidental Smiley character. Correct spelling of condition corresponding. Various capitals. Insert code tags.
# 2  
Old 01-09-2012
Code:
while read line
do
        cnt=$(echo $line | tr ' ' '\n' | egrep "select|update|delete|where" | wc -l)
        echo "$line" | nawk -v var="$cnt" '{if(var%2==0){print $0" --> success"}else{print $0" --> fail"}}'
done < infile

# 3  
Old 01-10-2012
Thanks,
jay... i will try out the code and post the result.

---------- Post updated 01-10-12 at 12:23 PM ---------- Previous update was 01-09-12 at 08:04 PM ----------

Hi jay,
nawk is not supported on my unix.
hence its not able to perform the above commanda.can you please do the above logic using some other way?also can you please put the print as echo commands so that results can be seen on the screen?
# 4  
Old 01-10-2012
If nawk is not supported, try with awk (or) gawk ..
# 5  
Old 01-10-2012
try with awk ( instead of nawk )
# 6  
Old 01-10-2012
Thanks raj and jay.
It is working now.
but this is not the desired result. please let me know if you want more examples of input and output

the script is checking each and every line and printing success.
Code:
*   Subsystem..: INFORMATICA ETL LOGGING AND CONTROL --> success
 --> success
*   Written by.: Yana Ruegsegger --> success
 --> success
* --> success
 --> success
*   --------------------------------------------------------------------------- --> success
 --> success
*           M A I N T E N A N C E   L O G --> success
 --> success
*   --------------------------------------------------------------------------- --> success
 --> success
*   Date     |  Programmer   |  Description --> success
 --> success
*   --------------------------------------------------------------------------- --> success
 --> success
*   07/24/07 | Dan Rolls     | Modified procedure to use create parameters for --> success
 --> success
*            |               |  current logging strategy --> success
 --> success
*   --------------------------------------------------------------------------- --> success
 --> success
*/ --> success
 --> success
( --> success
 --> success
in_source_session_seq_no IN NUMBER, -- ld_ctl_seq_no of the job to be copied (default template) --> success
 --> success
in_target_session IN VARCHAR2,      -- session name for job to be created --> success
 --> success
in_job_name IN VARCHAR2,        -- project name for job to be created --> success
 --> success
in_folder_name IN VARCHAR2,         -- folder name for job to be created --> success
 --> success
in_workflow_name IN VARCHAR2,       -- workflow name for job to be created --> success
 --> success
in_data_source IN VARCHAR2,         -- source for job to be created --> success
 --> success
in_data_target IN VARCHAR2,         -- target for job to be created --> success
 --> success
in_table_name IN VARCHAR2          -- table name for job to be created --> success
 --> success
) --> success


Last edited by vbe; 01-10-2012 at 07:42 AM.. Reason: code tags
# 7  
Old 01-10-2012
Pls post the entire input content ..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing answers to external program from KSH

I have asked this before but I haven't had any luck so far getting this to work. I use RCS(revision control system). When it runs if I pass the value 'unlock' to $3 its reassigned to $unlock. When I run the command (rcs -u'version number' 'filename') ti will ask me 1-(Do you want to break the lock... (5 Replies)
Discussion started by: pjones006
5 Replies

2. Shell Programming and Scripting

Automating a Java program using KSH

Hi Guys, We have a java program that basically install updates to an existing software. The java program consist of several screens asking user for choices (please see below for a detailed example) *** Screen 1 *** Please choose the operation you want to perform: 1. Install new... (5 Replies)
Discussion started by: maddmaster
5 Replies

3. Shell Programming and Scripting

convert ksh to C program

Hi Guys...is there a way to convert a .ksh script to .C program..? (3 Replies)
Discussion started by: aggars
3 Replies

4. Shell Programming and Scripting

Invoke perl program from Ksh

Hi all, Can I invoke a perl script from Ksh script and pass parameters to the perl script. Please do help me.. thanks Maha (10 Replies)
Discussion started by: mahalakshmi
10 Replies

5. Shell Programming and Scripting

ksh program run with different results by different users

Hi, I wrote a ksh program on Unix. One thing I don't understand: some users run it with different results. I suspect it's either "cat" or "grep" command. Basically, with one group of user, the 'cat' or 'grep' command is not getting the data I need and that changed the result. Is the above... (2 Replies)
Discussion started by: cin2000
2 Replies

6. Shell Programming and Scripting

grep within ksh program

Hi, is there problem with grep command when using ksh? I had the below command: /usr/bin/grep \""$Mon $NewDD\"" /tmp/timemanager/intlog.$$ >> /tmp/timemanager/log.$$ 2>/dev/null when I run ksh in debug mode, this command can not grep anything even the data is in the file. + /usr/bin/grep... (3 Replies)
Discussion started by: cin2000
3 Replies

7. Shell Programming and Scripting

ksh program with password

Hi, I am looking for a way to utilize password when the ksh program is launched. What's the standard or best way to do it? Thanks for your help! (5 Replies)
Discussion started by: cin2000
5 Replies

8. Programming

parameters from my program in c to a .ksh script

hi.. this is my question: it is possible transfer parameters from my program written in C to a .ksh script? how can i do it? i have a program in C, what is called from a .ksh script, and i need what the C program returns some values (parameters) please, help me - any idea thanks ... (2 Replies)
Discussion started by: DebianJ
2 Replies

9. Shell Programming and Scripting

Adding entry into crontab in ksh program

Hi falks, I have the following ksh function ,which adding entry to crontab during ksh program running: { print "Go\c" >/dev/null 2>&1 print '0 0 * * * su - ias -c "/home/orca/core-${SCHEMA_NAME}/CLI/cleanup_BRMS.ksh"\c' >/dev/null 2>&1 print "\033:wq!" >/dev/null 2>&1 } | \crontab -e... (2 Replies)
Discussion started by: nir_s
2 Replies

10. UNIX for Advanced & Expert Users

date program in ksh

#Author : kkodava #!/usr/bin/ksh #Use of this program is You can findout the no of days & day of starting and ending dates #usage no_of_days startdate<yyyymmdd> enddate<yyyymmdd> syy=`echo $1|cut -c1-4` smm=`echo $1|cut -c5-6` sdd=`echo $1|cut -c7-8` eyy=`echo $2|cut -c1-4` emm=`echo... (1 Reply)
Discussion started by: krishna
1 Replies
Login or Register to Ask a Question