Pass the output of a shell script to c++ program
Hi dear users,
I have a shell script that produce 3 outputs. i want to pass these 3 outputs to a c++ program. I know that i should use system() function for running the shell script but i do not know how to send the output of my shell script to my c++ program? for example iwant my c++ program to get 3 outputs(Acc,Get ,Third)and pass them to these 3 functions: Quote:
Thanks |
Quote:
Since your related thread involved others writing a program for you, why don't you start this one by posting what you've done and tried on your own first, and tell us where you're stuck?? |
Generally, pipes are used to pass the output of one program in as input to another program. A shell script is a program and most modern shells support pipes in various ways. When you say your script produces 3 different outputs, do you mean that it writes its output to three different file descriptors, or something else? As TB0ne indicates, some more detail about what you've tried would be very beneficial.
|
may be this helps:
first the code of the simple program: Quote:
Quote:
|
OK, that helps a little bit, but what do you want the program to do differently? Should it print the contents of all the files passed to it as command line arguments, try to run them as commands, or something else?
|
Pass the output of a shell script to c++ program Reply to Thread
hi again dear users. my shell script is something like this:
Code:
#!/usr/bin/awk -f i want to pass these three variables to my c++ code. i do not know exactly how would it be and how these 3 output can be send to a program that has something like this: Quote:
thanks for your kind and help. |
I think you need to read up on c++
Code:
#include <iostream> Code:
/path/to/Script.awk /path/to/logs/*log | /path/to/Fuzzy |
Quote:
The VERY FIRST HIT in Google for "how to pass command line arguments in C++" is: http://www.learncpp.com/cpp-tutorial...ine-arguments/ ...amazingly, it tells you how, and has examples. |
AND
I gave an example on how to open a file in c++ in your other thread. Which was in fact the first c/c++ I had written And remember that awk script is not doing anything useful , you need to adapt it |
Pass the output of a shell script to c++ program
Quote:
I try to do the job with the suggested code and try to add such a code in my cpp program. I compiled my program by makefile and there was no error but when i try to do /path/to/Script.awk /path/to/logs/*log | /path/to/Fuzzy there is some errors and one of them is this: Quote:
Quote:
thanks alot |
if i am not mistaken you said that your project is about fuzzy logic.
the information you give is not sufficient i guess. it is too fuzzy for us. :) it is better you give more information about your code and the command you give to run the program. |
Pass the output of a shell script to c++ program Reply to Thread
My c++ code is a code that assess risk based on fuzzy logic. I used a fuzzylogic library and then write such a code. my code is like this:
Code:
#include <iostream> Quote:
Thanks alot. |
you said
Quote:
Quote:
|
@samasara
your c++ code does not have a single cin, your Acc, Get and Third are all null.. You need to learn c/c++ , I'm not going to do it for you and regards the 'errors' Quote:
look, the code you posted.. Code:
sh FuzzyLogic.cpp How did you ever get this far? |
don't know why i'm doing this
Code:
using namespace std; |
All times are GMT -5. The time now is 02:58 AM. |