Remover Banner and SQL prompt from isql


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remover Banner and SQL prompt from isql
# 1  
Old 09-15-2009
Remover Banner and SQL prompt from isql

Hi,
I am using isql and putting the output in a file in a shell script in Linux.
However in my output i am getting the banner and a SQL prompt(at the start and the end of query output)
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>query output
SQL>


I need just the query result

Any ideas on how to acheive this?
# 2  
Old 09-15-2009
Like this?

Code:
awk '!/^+|\|/{sub(/^SQL>/, "");print}' file

# 3  
Old 09-15-2009
yes its working!!!thanks a ton
Could you please explain me the command as i am not familiar with awk
Thanks
# 4  
Old 09-15-2009
Quote:
Originally Posted by lifzgud
yes its working!!!thanks a ton
Could you please explain me the command as i am not familiar with awk
Thanks
Certainly. Awk syntax is based on a </condition/>{action} pattern that will process every line of the file.

Here, the condition is:
!/^\+|\|/ all lines that does not (the ! in front of the /condition/) start either with + or | (escaped as these are two regex operators)

The action:
{sub(/^SQL>/, "");print}' first replace the SQL> string by nothing if it is at the start of the line. Then, print the modified record.
# 5  
Old 09-15-2009
ok.But how did the Banner get removed?
# 6  
Old 09-15-2009
Quote:
Originally Posted by lifzgud
ok.But how did the Banner get removed?
Because I asked to print only the lines the are *not* starting with + or |. And the remaining lines that are printed are modified to get rid of the SQL prompt.
# 7  
Old 09-16-2009
Ok.Thank u so much!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using Isql for SQL SERVER to get the table rows counts in UNIX shell script to

need to create shell script to read the table's name from file and connect SQL SERVER using isql (odbcunix) i 'm able connect to database with below command line syntex but i could not get working in shell script with SQL and storing the row count in variable. isql -v DSN USERNAME PASSWD ... (6 Replies)
Discussion started by: pimmit22043
6 Replies

2. Solaris

Unable to move from rsc prompt to ok prompt

Hi, on sunfire v890 unable to move from rsc prompt to ok prompt, i have executed the command break. (9 Replies)
Discussion started by: manoj.solaris
9 Replies

3. UNIX for Dummies Questions & Answers

How to Change the % prompt to - prompt in UNIX?

how to Change the % prompt to - prompt in unix :wall: ---------- Post updated at 07:40 AM ---------- Previous update was at 07:38 AM ---------- How To display the last modification time of any file in unix ---------- Post updated at 07:40 AM ---------- Previous update was at 07:40 AM... (2 Replies)
Discussion started by: manjiri sawant
2 Replies

4. UNIX for Dummies Questions & Answers

Need help with banner.

is there a way to reduce the size of the banner? banner -w ? TIA (8 Replies)
Discussion started by: budz26
8 Replies

5. Shell Programming and Scripting

Handling SQL prompt through Perl expect module

Hi All, I have a doubt whether expect module in perl will work in SQL prompt or its applicable only for shell prompt ? Thanks, Arun V (2 Replies)
Discussion started by: arun_maffy
2 Replies

6. Shell Programming and Scripting

Duplicate file remover using md5sum--good enough?

This is not a typical question. I have a fully working script but I'm interested in optimizing it. I frequently back up photos and movies from my digital camera and cell phone to both my home/work desktops, laptops, wife's netbook, and my home NAS and often end up with multiple versions of the... (2 Replies)
Discussion started by: Michael Stora
2 Replies

7. Shell Programming and Scripting

isql input file with multiple sql statements

I've got: isql -U $USERID -S $SERVER -D $DATABASE -i inputfile.sql -o outputfile.txt in inputfile I have: go sql#1 go sql#2 go sql#3 go I also tried without "go" and with";" instead which did not work SQL statements will work if I paste them directly into the script and use EOF ... (0 Replies)
Discussion started by: Cailet
0 Replies

8. Solaris

bcp and isql for MS SQL Server on Solaris?

After dumping data from an Oracle database running on Solaris into a flat file, we need to run bcp and isql for MS SQL Server on the same Solaris box. Does Microsoft provide some tools that run on Unix? Thanks for your assistance. (2 Replies)
Discussion started by: tomstone_98
2 Replies

9. UNIX for Dummies Questions & Answers

Banner

How can I display a message to the crt whenever someone logs on? They do not see a unix prompt. I need to easily update this also. (2 Replies)
Discussion started by: Beetlejuice
2 Replies

10. UNIX for Dummies Questions & Answers

Banner command

Hey all, I want to use the banner/echo command to write messages on different console windows. I knew that before, but I completely forget how to do it ! I just remenber that /dev/pts/# is the number of the window. and it's useful. It would be great if someone knows how to solve my... (4 Replies)
Discussion started by: maxwell17
4 Replies
Login or Register to Ask a Question