Data export UNIX shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Data export UNIX shell script
# 1  
Old 05-14-2013
Data export UNIX shell script

Hi,

I want to write a shell script which connect to my database with the following credentials :

User name : user
PWD : rap_user_1

Hostname : app.Unix.Gsm1900.Org
Port : 7862
SID : PTNC1


Once connected to DB i want to fetch data with the help of a SQL statement and expoet that data in a Excel sheet and then i need to send an email to few ppl.

Please help me with the script.

# 2  
Old 05-14-2013
What have you tried?
# 3  
Old 05-14-2013
I tried sqlplus to connect to my database , but seems like SQLPLUS is not there
Code:
sqlplus -s user/rap_user_1@PTNC1
-ksh: sqlplus: not found [No such file or directory]
$ sqlplus


Last edited by Franklin52; 05-15-2013 at 03:25 AM.. Reason: Please use code tags
# 4  
Old 05-14-2013
The error states that the OS cannot find Oracle Database Utility: sqlplus in its PATH.

Check if you have variable ORACLE_HOME defined:
Code:
echo $ORACLE_HOME

If yes, check if sqlplus is available in bin directory:
Code:
ls $ORACLE_HOME/bin/sqlplus

If the utility exists, set your PATH to include $ORACLE_HOME/bin directory:
Code:
PATH=$PATH:$ORACLE_HOME/bin 
export PATH

You can put above in startup scripts to ensure that it is available each time you create a new session.
# 5  
Old 05-14-2013
An alternative with no sw cost is JAVA JDBC tool xigole jisql.

Converting delimited text to proper CSV is a task for a serious tool, but if you have no ',' or '"' in your data, you can just change the delimiter to comma. Now you have a CSV file. You need an attaching batch email client like mutt to send the file as an attachment with your message to your distribution list. Sometimes you can use uuencode to pack the csv for you, or you can send it as a 8 bit binary, using sendmail and various tricks.

You could turn it into an HTML table and send an HTML email. Users can paste the html table into excel.
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 export hive table data to a file on local UNIX?

Hi All , I am stuck on the below situation.I have a table called "test" which are created on hive.I need to export the data from hive to a file(test.txt) on local unix system.I have tried the below command ,but its giving the exception . hive -e "select * from test " > /home/user/test.txt ; ... (1 Reply)
Discussion started by: STCET22
1 Replies

2. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

3. Shell Programming and Scripting

Export data from database in Excel sheet with the help of Shell script and automated the report

Export data from database in Excel sheet with the help of Shell script and automated the report every day in the mornig. (1 Reply)
Discussion started by: neeraj617
1 Replies

4. Shell Programming and Scripting

Shell script to export data from Oracle table .

Hi, I want to write a shell script which will export data from oracle table . I don't want to save that data . I want the queries . Right now i am right clicking on the table and clicking on export as to my desktop . Please let me know if any one have any idea . (2 Replies)
Discussion started by: honey26
2 Replies

5. Shell Programming and Scripting

How to fetch data from oracle in unix shell script

Hi, How to fetch data from oracle database in unix shell scripting. list=`sqlplus -s ds_user/dsuser@EMI <<EOF set feedback off set serveroutput on set heading off set pagesize 0 set tab off select IP_ID from table / exit EOF` The output is not what i expected.I need output in... (4 Replies)
Discussion started by: Anusha_Reddy
4 Replies

6. Shell Programming and Scripting

converting the data type in unix shell script

I am writing a unix shell script that will extract records from table and write into a file. ====================================== #! /bin/ksh ############################ # AFI Monitor Script ############################ . /db2/uszlad48/sqllib/db2profile export... (5 Replies)
Discussion started by: kmanivan82
5 Replies

7. Shell Programming and Scripting

help for writing shell script to export table data

Hi All, I need to write a shell script(ksh) to take the tables backup in oracle(exporting tables data). The tables list is not static, and those are selecting through dynamic sql query. Can any body help how to write this shell script. Thanks, (3 Replies)
Discussion started by: sankarg
3 Replies

8. Shell Programming and Scripting

How to extract data using UNIX shell script?

Hello All, I am starting with UNIX. Any help is highly appreciated. How to extract data using UNIX shell script? And how do you export data using UNIX shell scripts into Microsoft Excel format? Thank you. (3 Replies)
Discussion started by: desiondarun
3 Replies

9. Shell Programming and Scripting

unix script to export data from csv file to oracle database

Hello people, Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these... (3 Replies)
Discussion started by: vinayagan
3 Replies

10. UNIX for Dummies Questions & Answers

How to export data file from Unix

Hi, I am searching a way to export data file on Unix to SQL server on a daily bases. Any one has any ideas? Thanks in advance! (20 Replies)
Discussion started by: whatisthis
20 Replies
Login or Register to Ask a Question