Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    138

    Unanswered: 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

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    780

    Re: return a string from script into C-Programm

    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.

  3. #3
    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

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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);
    ---
    "It does not work" is not a valid problem statement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •