piping from C to python in UNIX


 
Thread Tools Search this Thread
Top Forums Programming piping from C to python in UNIX
# 1  
Old 05-04-2008
piping from C to python in UNIX

Hi,

I'm trying to wrap my head around piping in C - I've got a small C program that forks and pipes stuff from the child process to the parent process.

Currently the child process calls a C program that squirts out random numbers which then pipes the result to the parent process.

The parent process reads the pipe and simply prints the random number.

What I would like to do is then use this piped integer in a python program.

So firstly I think I have to include the python library within the C program.

#include <python2.4/Python.h>

then call python with:

Py_Initialize();

But when I call this the gcc compiler gives me the error:
undefined reference to 'Py_Initialize'

So I'm guessing that the header file I'm using is incorrect..?

the python version I'm using is:

Python 2.4.3 (#1, Jun 13 2006, 16:41:18)

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Applying python on all the files in one folder --UNIX

Dear all, I know this might be a simple and silly question but I am struggling with it I have a long unix script and in a section of if I want to use a python script which should select all the files and run the script on it (as a whole) the loop I have is selecting file by file and I dont know... (2 Replies)
Discussion started by: A-V
2 Replies

2. Homework & Coursework Questions

Unix Piping Problem

Hey guys. I'm very new to Unix. I'm pretty fluent in Java and C, but I have never actually used Unix for anything. I am in an Operating Systems course now and I have an assignment to write a piece of code that involves forks and piping. I'm stuck. 1. The problem statement, all variables and... (6 Replies)
Discussion started by: itsjimmy91
6 Replies

3. Shell Programming and Scripting

Piping to a python script

Hello, I have a python script (not created by me), let's call it myscript, which I call with several parameters. If I don't provide the --password parameter, the script will ask the user to input the password. So I run the script like this: /wherever/myscript --username=whoever... (3 Replies)
Discussion started by: gplayersv
3 Replies

4. Shell Programming and Scripting

Exit code from piping in unix shell script

Hi , I have following code in my shell script : "$TS_BIN/tranfrmr" "${TS_SETTINGS}/tranfrmr_p1.stx" "${TS_LOGS}/tranfrmr_p1.err" | ( "$TS_BIN/cusparse" "${TS_SETTINGS}/cusparse_p2.stx" "${TS_LOGS}/cusparse_p2.err" | ( "$TS_BIN/tsqsort" "${TS_SETTINGS}/srtforpm_p3.stx"... (8 Replies)
Discussion started by: sonu_pal
8 Replies

5. Shell Programming and Scripting

Piping Unix Variable Array values into AWK

#ksh Here is my code: ERRORLIST="43032 12001 12002 12003 12004 34019 49015 49016 49017 49018 49024 49025 49026 58004 72003 12005 12006 12007 12008 12011 12012 16024 16023" for ERROR in ${ERRORLIST} do awk -v l="$lastdate" '/^....-..-../&&$0>l{d=$0}d&&/Error: '"${ERROR}"'/{print... (3 Replies)
Discussion started by: k1ko
3 Replies

6. Shell Programming and Scripting

Need your help for the spell checker in unix or python

Hi, Want to know is there any command to correct the spelling using unix or python? Unix command "spell" will give only the list of the incorrect words . But i want the output along with the corrected word . Thanks in advance (1 Reply)
Discussion started by: vini
1 Replies

7. Shell Programming and Scripting

Python in UNIX

Hi, I am going to handle a project that uses Python on AIX or SunSolaris Plateform. Please tell me what is Python and how and why we should use Python. Please suggest. Thanx. (2 Replies)
Discussion started by: sanjay1979
2 Replies

8. Programming

Java with Unix (Redirection + Piping)

Hi, To explain this question I will have to go into a bit of detail. I hope you don't mind. currently I have a log handler (an already compiled c++ version) and what it does is makes a log file and writes all the unix output (echo, etc) of a script to that log file. To me the log_handler is... (3 Replies)
Discussion started by: fluke_perf
3 Replies

9. UNIX for Dummies Questions & Answers

Piping in UNIX

All, I am a UNIX novice with a question that I hope you can help me with. I have a UNIX application called "Tole" that formats and displays specific information about customers. I can display the information for up to 30 customers by seperating customer IDs using commas in this format: Tole -c... (3 Replies)
Discussion started by: simo007
3 Replies

10. UNIX for Advanced & Expert Users

Python, HTML, and Unix

Hi Experts, This may be the wrong category for posting my question, or it could be the perfect category to post. I have no idea how difficult my problem is. I have python 2.3 installed in my server machine. I am trying to create a web page with python script in it. Now this can be a .html... (1 Reply)
Discussion started by: davidfrank
1 Replies
Login or Register to Ask a Question
PYTHON-CONFIG(1)					      General Commands Manual						  PYTHON-CONFIG(1)

NAME
python-config - output build options for python C/C++ extensions or embedding SYNOPSIS
python-config [ --prefix ] [ --exec-prefix ] [ --includes ] [ --libs ] [ --cflags ] [ --ldflags ] [ --help ] DESCRIPTION
python-config helps compiling and linking programs, which embed the Python interpreter, or extension modules that can be loaded dynamically (at run time) into the interpreter. OPTIONS
--cflags print the C compiler flags. --ldflags print the flags that should be passed to the linker. --includes similar to --cflags but only with -I options (path to python header files). --libs similar to --ldflags but only with -l options (used libraries). --prefix prints the prefix (base directory) under which python can be found. --exec-prefix print the prefix used for executable program directories (such as bin, sbin, etc). --help print the usage message. EXAMPLES
To build the singe-file c program prog against the python library, use gcc $(python-config --cflags --ldflags) progr.cpp -o progr.cpp The same in a makefile: CFLAGS+=$(shell python-config --cflags) LDFLAGS+=$(shell python-config --ldflags) all: progr To build a dynamically loadable python module, use gcc $(python-config --cflags --ldflags) -shared -fPIC progr.cpp -o progr.so SEE ALSO
python (1) http://docs.python.org/extending/extending.html /usr/share/doc/python/faq/extending.html AUTHORS
This manual page was written by Johann Felix Soden <johfel@gmx.de> for the Debian project (and may be used by others). November 27, 2011 PYTHON-CONFIG(1)