Invoke unix script using c program


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Invoke unix script using c program
# 1  
Old 09-27-2010
Invoke unix script using c program

hi

i want to invoke a unix script in a C program and also return some value from the script to the C program to use that value further.

Basically i am doing a Lookup operation in this unix script and returning the looked up data from a oracle database table..

please help me invoke as well as return dat from the script to C program.
# 2  
Old 09-27-2010
A general answer -
1. Preferred answer - develop Pro*C application that does what your sql script does

2. use popen in read mode to execute a shell script; as the shell script generates text you can read the data from a file descriptor.

popen example:
Code:
char tmp [1024]={0x0};
FILE *in=popen("/path/to/myshellscript.sh", "r");
while fgets(tmp, sizeof(tmp), in)!=NULL)
{
        // tmp contains one line of data process with it here
}
pclose(in);

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem while Invoke Shell Script function from Java Program

Hi, I have create a Shell Script, with one function. I want to call the script file in Java Program. It working fine. but the problem is the function in the Shell Script is not executed. Please suggest me, Regards, Nanthagopal A (2 Replies)
Discussion started by: nanthagopal
2 Replies

2. Shell Programming and Scripting

how to invoke external program and capture its output

Hi all, I am using an external binary to view memory starting from a specific address and i want to automate this via PERL however there are problems. Hope you can help me ..thx The output of the programme is like below: bash-3.2$ mem_disp 12B21D20 100 Opening RO Data Memory File scp.ro... (4 Replies)
Discussion started by: ekckabatop
4 Replies

3. Shell Programming and Scripting

Invoke a script in UNIX using Excel Macro

Hi, I am using Send Keys to connect to UNIX server and invoke a script . Is there an alternate way to connect to UNIX server using Excel macro and invoke a UNIX Shell script? Anu (2 Replies)
Discussion started by: anandita.jha
2 Replies

4. UNIX and Linux Applications

how to invoke the mail from unix ?

How to send mail to users from linux machine when ceratin task finished ? (1 Reply)
Discussion started by: saku
1 Replies

5. Shell Programming and Scripting

Script of invoke an email program

Is it possible that a shell script invokes a windows mailing application like Lotus Notes and creates a mail and sends it ? (2 Replies)
Discussion started by: csrohit
2 Replies

6. Solaris

How to invoke remote java program from ssh

How can i invoke java program from MC1, when I connect remotely to execute can I set classpath etc. ____________ <-------------->____________________ |..................|<-------------->|...............................| |..................|<-------------->|...............................|... (2 Replies)
Discussion started by: vishnu559
2 Replies

7. Shell Programming and Scripting

How to invoke a perl script from java program

Hi: I need to invoke a perl script from a java applet program in UNIX operating system.. Can you please suggest me!!! (4 Replies)
Discussion started by: grajesh_955
4 Replies

8. Shell Programming and Scripting

Invoke perl program from Ksh

Hi all, Can I invoke a perl script from Ksh script and pass parameters to the perl script. Please do help me.. thanks Maha (10 Replies)
Discussion started by: mahalakshmi
10 Replies

9. Shell Programming and Scripting

Invoke java program in script

Hey all, My boss tasked me with the job to write a script which would invoke various java programs, the thing is I don't know much about shell scripting so would you experts help me out? Here is the requirement - 2 applications written in java: App_A and App_B -... (0 Replies)
Discussion started by: mpang_
0 Replies

10. UNIX for Advanced & Expert Users

Invoke java program in different processc d

I have a simple script like this: for file in $dodfiles; do ./rundod $file done $dodfiles is an array of file names selected rundod is a script which invokes a java progrm which process a data file all the processing message logged into a log file in order to extract and analyze the... (1 Reply)
Discussion started by: liux99
1 Replies
Login or Register to Ask a Question