Sponsored Content
Top Forums Shell Programming and Scripting Reading line by line from unix script Post 302406306 by chamajid on Monday 22nd of March 2010 01:48:47 PM
Old 03-22-2010
Not quite what I need.

Thanks for such a quick reply. What I am trying to do is put the parameter into the delete sql and run it. I am using the BTEQINF file to run the sql.

So my question is, how can I read the paramter value from fiscper.parm and run the DELETE SQL with correct tablename and number values.

Here is what I wrote:



Code:
while read -r tbl_name st_dt en_dt
do
     tbl_name=`cut -d";" -f1 /transfer/sap_fin/sap_rsync/cca/fiscper.parm`
     st_dt=`cut -d";" -f2 /transfer/sap_fin/sap_rsync/cca/fiscper.parm`
     en_dt=`cut -d";" -f3 /transfer/sap_fin/sap_rsync/cca/fiscper.parm`
     /upapps/inf/dev/scripts/bteqinf > /upapps/inf/dev/scripts/sap_bi_fin/findbt40;
     'DELETE FROM FINDBT40."$tbl_name" where fiscper between "$st_dt" and "$en_dt";'
     /upapps/inf/dev/scripts/bteqinf <<-!
done

What this script is doing is putting all the first column values into one

something like

DELETE FROM FIN427
FIN475
FIN474
FIN 476
where fiscper between 2010003
2010001
2010001
2010001

and 2010003
2010003
2010003
2010003


and I want it to be able to run the sql when I run the script.

DELETE FROM FINDBT40.FIN427 where fiscper between 2010003 and 2010003;

DELETE FROM FINDBT40.FIN475 where fiscper between 2010001 and 2010003;

DELETE FROM FINDBT40.FIN476 where fiscper between 2010001 and 2010003;

DELETE FROM FINDBT40.FIN474 where fiscper between 2010001 and 2010003;

edit by bakunin: please note that code-tags around code are a free-of-charge add-on of this forum. Don't be shy to use them yourself from now on.

Last edited by bakunin; 03-22-2010 at 05:24 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

reading a line into a variable in unix

hi... i need to open a file and read it line by line, and capture that it in to some variable and manipulate... i need to get a line in to a variable please help :confused: (1 Reply)
Discussion started by: lmadhuri
1 Replies

2. Shell Programming and Scripting

Reading a file line by line and processing for each line

Hi, I am a beginner in shell scripting. I have written the following script, which is supposed to process the while loop for each line in the sid_home.txt file. But I'm getting the 'end of file' unexpected for the last line. The file sid_home.txt gets generated as expected, but the script... (6 Replies)
Discussion started by: sagarparadkar
6 Replies

3. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

4. Shell Programming and Scripting

Reading line1 with line2 and line 2 with line 3 in unix

Hi, I have a requirement where i have to read a file line by line and see if the string(fixed postion 10 to 15 in the file) in line 2 is greater than string in line 1. I have used following code while read LINE1 do current_inv_no=$(echo "$LINE1" | cut -c 10-15) read... (2 Replies)
Discussion started by: chethanbg2010
2 Replies

5. Shell Programming and Scripting

Reading a line and the next line in a shell script

Hi, I'm trying to read a line and the next line in a shell script by executing the following code: for i in `seq 1 $numLines`; do line=$(sed -n '{$i}p' outputFile) echo $line done $numLines contanis the outputFile's number of lines. It doesn't work and I cannot... (8 Replies)
Discussion started by: JuanPerez
8 Replies

6. 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

7. Shell Programming and Scripting

Replace values in script reading line by line using sed

Hi all, Let's say I have a script calling for the two variables PA_VALUE and PB_VALUE. for pa in PA_VALUE blah blah do for pb in PB_VALUE blah blah do I have a text file with two columns of values for PA and PB. 14.5 16.7 7.8 9.5 5.6 3.6 etc etc I would like to read this... (7 Replies)
Discussion started by: crimsonengineer
7 Replies

8. UNIX for Dummies Questions & Answers

UNIX Help for reading line

Hi there, I am trying to read the content such that if there is 'adsmsext.dll', it will read everything from line one until it reads line 6 with 'C:' then it will terminate at line 5. 1. C:\WINDOWS\system32\adsmsext.dll NT AUTHORITY\Authenticated Users:R 2. ... (5 Replies)
Discussion started by: alvinoo
5 Replies

9. Shell Programming and Scripting

Shell script UNIX to read text file line by line

i have a text file as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name data_file.txt column_name file_name col1 file1 col2 file2 col3 file1 col4 file1 col5 file2 now, i would like to... (4 Replies)
Discussion started by: tester111
4 Replies
exit(1)                                                            User Commands                                                           exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 07:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy