The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing values from sql to shell script sachin.gangadha Shell Programming and Scripting 3 04-22-2008 11:11 PM
returning values from shell script to calling C program nehamore Shell Programming and Scripting 2 02-04-2008 11:09 AM
passing oracle parameters back to Shell satnamx Shell Programming and Scripting 4 01-16-2007 09:59 AM
Passing Values from a shell script dhananjaysk Shell Programming and Scripting 6 04-06-2006 09:33 AM
passing parameters from a shell script to sqlplus phani Shell Programming and Scripting 2 03-13-2005 08:41 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-14-2005
Rajeshsu Rajeshsu is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 11
Passing Parameters and getting values back from a c program to Shell script

I am having a shell script which has to be called from a C program. I have to pass two parameters to this script. HOw can I do that?

eg:
int main()
{
char st1[20];
char str2[20];
// call a shell script
call_sh(str1,str2) where call_sh is the name of the shell script.
then i need to get the return status of the shell script also
}
how can i do this


Please Help me in this.
  #2 (permalink)  
Old 08-14-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Please read our rules and note:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.

I have deleted the other post where you ask the same question. Please do not post this question a third time.
  #3 (permalink)  
Old 08-15-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Check the man pages for the following syscalls: system, exec, fork.

You should be able to do it using these.
  #4 (permalink)  
Old 08-15-2005
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
You can also call popen() to read the stdout of the shell.

man popen pclose
  #5 (permalink)  
Old 08-22-2005
Rajeshsu Rajeshsu is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 11
Hello Blowtorch

Can you explain me about that with an example...

I used execlp("shell script name,"arguments",0) to call my shell program. But after execution, the shell program;s value is not available to my c program. But I want that value. So how can I do that. Please explain me with an example.
  #6 (permalink)  
Old 08-22-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Check man popen.. jim's suggestion.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0