I am trying to write a script which will generate output to a file based on input files on basis of a pattern which I am able to do so. But, I am stuck as I am trying to connect this to database server. Below is my command and output details.
Input Code
File output.
Now, I want to read this new file and write a select statement in SQL by reading the complete file. But the only condition is that this newly created file contains details as above and I need to use comma to include all the lines in the file so that I will be able to use a single select statement in sql.
Now I need to use these lines from alllpnfiles.dat into a single select statement as below.
Regards.
GVK
Moderator's Comments:
Note that this thread has been moved from the "How to Post in the The UNIX and Linux Forums" forum to the "Shell Programming and Scripting" forum.
Last edited by Don Cragun; 11-26-2017 at 04:53 AM..
Reason: Note forum change.
I am trying to write a script which will generate output to a file based on input files on basis of a pattern which I am able to do so. But, I am stuck as I am trying to connect this to database server. Below is my command and output details.
Input Code
File output.
Now, I want to read this new file and write a select statement in SQL by reading the complete file. But the only condition is that this newly created file contains details as above and I need to use comma to include all the lines in the file so that I will be able to use a single select statement in sql.
Now I need to use these lines from alllpnfiles.dat into a single select statement as below.
Regards.
GVK
Your pipeline includes a sort, but your output clearly is not sorted???
So, assuming that the output does not need to be sorted, we can replace the rest of the pipeline with a single invocation of awk:
But, of course, since no sample input was provided, the above code is completely untested. If, despite your sample output, you really do need the output to be sorted, you can modify the for loop in the END clause in the above awk code to feed the list to sort and feed the output from sort into another for loop to print the results. Or, the awk available on some systems provides a function that could be used to sort the pn[] array before printing the results.
And, you haven't told us what operating system or shell you're using. If you're using a Solaris/SunOS system, change awk in the above code to /usr/xpg4/bin/awk or nawk.
Last edited by Don Cragun; 11-26-2017 at 05:01 AM..
Reason: Fix tabs.
You seem to
- be missing a line terminator between the filedate assignment and the awk command.
- operate on a gzipped file, which is not *nix text - awk sensibly works on text only. gunzip first.
Last edited by RudiC; 11-27-2017 at 11:39 AM..
Reason: typo...
I made changes and the script is executing. But the output which I am getting is not a single in but in iterations.
The input file has 3 lines and output generated is as follows.
I made changes and the script is executing. But the output which I am getting is not a single in but in iterations.
The input file has 3 lines and output generated is as follows.
OUTPUT
The above output is from a single file only.
Regards.
GVK
Please try using the code I suggested in post #2: exactly as shown above without removing line breaks and without adding line breaks that are in the above suggestion. There is a HUGE difference in the behavior of:
and:
This User Gave Thanks to Don Cragun For This Post:
Hi All,
I am newbie to unix shell scripting. I want to connect to oracle database using shell script. I know how to connect DB using user name and password but my question is if my password is having '@' sign then how to connect.
I have tried like below,
cnt=`sqlplus -s /nolog << EOFSQL
... (3 Replies)
Hi Unix Gurus,
I have a requirement to write a script, Oracle DB gets referesh every 6hrs, hence we need write a script to connect to the database , if it connects it should generate a file to proceed the next job application or when an error when connectiong to DB it should not generate any... (8 Replies)
HI,
i want to write a script (Linux) that:
1) connect to a database oracle
2) execute some store procedure.
Can anybody help me, please?
Thanks a lot
Andrew (3 Replies)
Hi! Everyone
I am new to the shell scripting basically.I have been asked to create a shell script that connect to a oracle database to read data from a particular schema then spool it into a csv file then email to customer.
Can anybody let me know how to go about that.
I have create... (14 Replies)
I am trying to connect to database db2 through shell script.
The process I am trying is
> db2
It gives me error Access Denied.
While checking for access I have the rights.
Is there ant other way round..?
Please help. (3 Replies)
Hi,
Can anyone please give me a script or let me know how to connect to a sybase database and execute a query using Korn shell scripts.Am new to Unix but i need to do this ASAP.
Please help.
Thanks,
Gops (7 Replies)
please, help me-....
i need connect to a database Sybase IQ 12 and I don't know if i can do it using a shell program.
if it's posibble, please tell me how...
please, help me, because I don't know what to do....
thanks...
jonathan (1 Reply)