PDA

View Full Version : unix shell scripting question


adip
06-04-03, 09:45
me
trying to run a select statment
select * from x >a.txt
this does not work
wheras
select * from x works

What is teh redirection operator required

sathyaram_s
06-06-03, 20:25
Just a thought ....

Can you have your statement within quotes
"select * from x" > a.txt

Originally posted by adip
me
trying to run a select statment
select * from x >a.txt
this does not work
wheras
select * from x works

What is teh redirection operator required

LKBrwn_DBA
06-16-03, 19:10
In unix shell sript you can do something like this:

#!/bin/ksh
sqlplus <usr>/<pw> <<!
spool a.txt
select * from x;
spool off
exit
!

And also like this:

#!/bin/ksh
sqlplus <usr>/<pw> <<! >a.txt
select * from x;
exit
!

aruneeshsalhotr
07-09-03, 20:09
If u are using sqlplus, kindly use the following command and you would be fine with the same.

script a.txt
sqlplus user /password
select fname, lname, orderid from prod_table;
quit
exit

now you can do a
cat a.txt
cat a.txt | mail user@domain.com

pooja
07-15-03, 11:50
another solution

isql -U<username> -P<pwd> -S<servername> -D<dbname> -oa.txt <<-EOF
select * from table
go
EOF

Pooja