If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > return a string from script into C-Programm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-26-03, 12:21
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
return a string from script into C-Programm

Hello friends,
from my C-Programm I make a SystenCall like this :
tmp=system(answer.sc)

answer.sc is a ShellScrip witch returns a string like "Hello"

How can I use this string "hello" in my C-Programm.

I think the script needs an "exit value"

But I donīt know how to use it.

Any solutions ???

Many thanks !

Greetings from Germany
Peter.F
Reply With Quote
  #2 (permalink)  
Old 10-28-03, 07:39
gurey gurey is offline
Registered User
 
Join Date: Aug 2003
Location: Argentina
Posts: 780
Re: return a string from script into C-Programm

Quote:
Originally posted by fla5do
Hello friends,
from my C-Programm I make a SystenCall like this :
tmp=system(answer.sc)

answer.sc is a ShellScrip witch returns a string like "Hello"

How can I use this string "hello" in my C-Programm.

I think the script needs an "exit value"

But I donīt know how to use it.

Any solutions ???

Many thanks !

Greetings from Germany
Peter.F
Hi Peter,

You talk about: tmp=system(echo "thi is string") or tmp=system(`execute same`).

Gustavo.
Reply With Quote
  #3 (permalink)  
Old 10-28-03, 13:19
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
Hello Gustavo,
thank you for post reply. I think I have not find the right words for my question.
I try it later with some examples for better understanding.

Thanks

Peter.F
Reply With Quote
  #4 (permalink)  
Old 10-28-03, 17:22
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,454
Quote:
Originally posted by fla5do
Hello Gustavo,
thank you for post reply. I think I have not find the right words for my question.
I try it later with some examples for better understanding.

Thanks

Peter.F
I think you should use _popen() instead of system().

FILE *f;
char output[256];

f = _popen("answer.sc", "r");

if ( f != NULL) output = fgets(output, 256, f);

_pclose(f);
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On