can a shell script interact with database?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting can a shell script interact with database?
# 1  
Old 07-24-2007
Java can a shell script interact with database?

Hi All,

Language like C,Java can interact with database..and can use database information .. can a shall script do this?

if yes thn plz guide me.....

thankx
# 2  
Old 07-24-2007
Yes u can interact with database. See below for the pseudo code

Code:
...
sqlconnect()
{
        sqlplus -s  scott/tiger@ORACLE << EOF
        select sysdate from dual;
        EOF
}
...

sqlconnect

You can also search the site for more details. Check this link Oracle Connect
# 3  
Old 07-24-2007
The unit of execution in a shell is a process. You are unlikely to be able to make a single transaction span multiple processes. If you need multiple steps within a single transaction you will need to generate the sql to pipe into a program like sqlplus.
# 4  
Old 07-24-2007
Code:
isql database_name <<!
select * from table_name
!

you can try this logic if you are using infomix
# 5  
Old 07-24-2007
Quote:
Originally Posted by srikanthus2002
Code:
isql database_name <<!
select * from table_name
!

you can try this logic if you are using infomix
Pretty much I have used only dbaccess for informix
is isql a supported client for informix. Smilie
# 6  
Old 07-24-2007
Quote:
Originally Posted by matrixmadhan
Pretty much I have used only dbaccess for informix
is isql a supported client for informix. Smilie
Matrixmadhan,
Before IBM bought Informix in 2001, Informix had separated its development
tools into three different groups:
1) Informix 4GL (for programmers).
2) isql (for non-programmers).
3) dbaccess (for database administrators).

Both 'isql' and 'dbaccess' have a lot of commom functions, but there are
several mutually exclusive functions.

Among other functions, 'dbaccess' does not have 'Forms' or 'Reports'.

Among other functions, 'isql' cannot create stored procedures nor perform
some database and table maintenance.

As far as I know, IBM-Informix supports both 'isql' and 'dbaccess'.
# 7  
Old 08-09-2007
Quote:
Originally Posted by srikanthus2002
Code:
isql database_name <<!
select * from table_name
!

you can try this logic if you are using infomix
Hi Srikanth,

Suppose I need to capture a Value that is the result of the query
How do i do it.
Like

Select x from Tablex where y='56';
I need the value x to be stored in a variable for further processing
How do I accomplish this ??

Regards
Srikanth GR
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expect script - Interact help

Hi Guys, Further to my post yesterday I have got round the issue of not being able to use expect by using one of our unix machines to have the script running instead of the jumpbox itself. However my issue is I now have an extra bit it the script which is shh to the jumpbox which requires a ras... (1 Reply)
Discussion started by: mutley2202
1 Replies

2. Shell Programming and Scripting

can a nohup'ed ksh script interact with user

I have a long running ksh script that I need to run with "nohup" in the backgound which is all well and good but at the very start of the script it needes to output to the screen to query the user and accept a response before continuing. Any thoughts on how to accomplish this other than... (11 Replies)
Discussion started by: twk
11 Replies

3. Programming

How could I interact with shell script from webportal written in php?

Hello, I am new on PHP scripting .I have shell scripts which I an running currently from linux server but now I want to make a web portal from where I will run all my scripts but the problem is all my scripts ask for parameters so I am getting confused how could I run my shell script from web... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

4. Shell Programming and Scripting

Expect script exiting too fast if used without interact.

Hi I'm working on an Expect script that is supposed to log-into a remote server and run some steps and exit. In the script I first spawn a 'ssh' session to the server and then after logging in I 'send' all the necessary steps ( with a '\r' at the end, so that they get automatically executed the... (3 Replies)
Discussion started by: clakkad
3 Replies

5. Shell Programming and Scripting

Switch from one database to other using shell script

Hi all, This is my first ever post to any forum so, dont let this go in vain...........:) Here is the scenario........ I have logged into the unix where oracle_sid is initialized for some X database in the .profile. I have a unix script where some sql query which fetches data from X... (3 Replies)
Discussion started by: sachinkl
3 Replies

6. Programming

Need help on Shell script for database maintainace..

Hi All, I have to perform some tasks for database maintainace. I am using postgresql on RHEL 4.4. 1) I have to run "vacuumedb" on the database as postgres user. 2) I have to reindex the database as postgres user. Now i want to write shell script to do these tasks one... (3 Replies)
Discussion started by: ashokkumar.p
3 Replies

7. Shell Programming and Scripting

How to make shell script interact with program

Hello all! I have a C program that runs on a loop, prompting the user for input until it is exited. I want to create a shell script that can run this program and provide input. How can I do this? I have investigated 'expect' and piping to stdin, but haven't had any success. Any help is... (2 Replies)
Discussion started by: radish04
2 Replies

8. Shell Programming and Scripting

get result from database into shell script

hi, I have a script that will logon to a database siebel and do the select query and then get the result in command prompt of unix.Below the script. #!/bin/ksh . $HOME/conf/systemProperties/EnvSetup.properties #set -x while read i do echo $i connect1=`sqlplus -silent... (1 Reply)
Discussion started by: ali560045
1 Replies

9. Shell Programming and Scripting

Connection to database through shell script

Hi when i am calling the shell script with two parameter like id and date it works fine.But the same shell script is call by java application it gives the error as shown below Thu Jan 8 04:13:22 EST 2009|The Get Segment Process Failed: SP2-0306: Invalid option. Usage: CONN where <logon>... (1 Reply)
Discussion started by: ravi214u
1 Replies

10. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies
Login or Register to Ask a Question