using the output of select


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using the output of select
# 1  
Old 05-08-2009
Question using the output of select

hi,
i need to use the output of select query.
the output i get using
"X=`sqlplus -s $var1/$var1<<eof
select port from table1;`
echo $X "

is

"port ----- 2000"
now i want to use only 2000 in my next command.
hw do i do it?
# 2  
Old 05-08-2009
Use
SET HEADING OFF;

This statement should be immediately after you login to sql.


Ideally this is the way it has to look.

"X=`sqlplus -s $var1/$var1<<eof
SET HEADING OFF;
select port from table1;`
echo $X "


Let us know if this worked or not..
# 3  
Old 05-08-2009
using o/p of select.

thanks a lot helper..
Actually i need two different ports from two different tables.
if i use the earlier script, echo $X shows two ports.
but the next netstat command uses only the first port.
hw can i use the result of echo $x ,say 2000 2001 in netstat command ,to chk whether they r up?
# 4  
Old 05-08-2009
MySQL

Use for loop and use the command netstat

"X=`sqlplus -s $var1/$var1<<eof
SET HEADING OFF;
select port from table1;`
echo $X "
for i in `echo $X`
do
netstat -i $X
done
# 5  
Old 05-08-2009
output of select

hi helper,
thanks.
it worked but with a simple change.ie netstat -an|grep $i
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print the output of a select query using shell script?

HI, I want to connect to database and fetch the count from a table. The sql query is as below : select count(*) from table_test where test_column='read'; How can I print the output of this statement using shell script. Thanks in advance. (4 Replies)
Discussion started by: confused_info
4 Replies

2. Shell Programming and Scripting

How to process select list of files and output to the same file?

Hi, I've a list of files ac_info.tps, subscription_array.tps, .......and many other files one of the file, bin_range_list.tps has the following content CREATE OR REPLACE TYPE "BIN_RANGE_LIST" AS TABLE OF BIN_RANGE_ELEM; / grant execute on... (4 Replies)
Discussion started by: jediwannabe
4 Replies

3. UNIX for Dummies Questions & Answers

Select text between current date and output to new txt file

Hi guys, brand new to this thread and very very new to UNIX...so go easy please! Anyway I have a file that looks like this: >>-------------------------------------------------------------------------- Date/Time/Eng. : 2012-06-22 / 00:26 / DS Reported problem : (SD) ... (5 Replies)
Discussion started by: martin0852
5 Replies

4. Shell Programming and Scripting

Select Unique Value

HOW CAN I SELECT AN UNIQUE STRING FROM A FIELD? ACTUALLY I WANT TO PRINT RECORDS THAT 2ND FIELD OF THAT HAVE ONE CHARACTER AND IT MUST BE "P" AWK '$2~"" {PRINT $0}' IN > OUTBUT THIS CODE PRINT ALL RECORDS WHICH 2ND FIELDS OF THEM START WITH "P" AND MAY CONTAINS ANOTHER CHARACTER! (1 Reply)
Discussion started by: saeed.soltani
1 Replies

5. Shell Programming and Scripting

sql select command output formatting in shell script

Hi, I need to connect to the database and retrieve two variables from the database and store them in a variable,out of these two variables I need to get lastdigit appended to the variable 1 retrieved and variable 2 with out any modification in short select var,data from usage; o/p=... (1 Reply)
Discussion started by: rkrish
1 Replies

6. Shell Programming and Scripting

Running a select script through UNIX and sending output to file

Hi, (Oracle, AIX) I have googled this and searched this forum, however I haven't had much luck with an answer and have tried several different things. Basically I have a SQL select statement which generates a whole load of UPDATE statements, I want to run the select statement via... (13 Replies)
Discussion started by: dbchud
13 Replies

7. Boot Loaders

Reboot and Select Proper Boot device or insert Boot media in select Boot device and press a key

Hello, I have kubuntu on my laptop and now I decided to switch to Windows 7. I made the bios settings properly (first choice is boot from cd\vd) but I see the error " reboot and select proper Boot device or insert Boot media in select Boot device and press a key " I have tried CD and... (0 Replies)
Discussion started by: rpf
0 Replies

8. Shell Programming and Scripting

select data from oracle table and save the output as csv file

Hi I need to execute a select statement in a solaris environment with oracle database. The select statement returns number of rows of data. I need the data to be inserted into a CSV file with proper format. For that we normally use "You have to select all your columns as one big string,... (2 Replies)
Discussion started by: rdhanek
2 Replies

9. Shell Programming and Scripting

Select Script

Dear Members:- i want to make this script 1- i have a log directory /export/home/roxy/log 2- file name in this directory with this format filename_DD_MM_YYYY_%H%M%S.log i want to make script for example: # script.sh _09_04_2009_ _10_04_2009_ this script make select to log file into... (4 Replies)
Discussion started by: dellroxy
4 Replies

10. Windows & DOS: Issues & Discussions

Want to use the output of Select statement in Unix script

Hi, I have a UNIX script which calls SQL Select statement: Now i want to use the output of that select statement within my UNIX script so as to call different shell script depending upon the output of the select statement. Can anyone help me in this regard. TIA Akhil Goel (4 Replies)
Discussion started by: akhilgoel9
4 Replies
Login or Register to Ask a Question