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-COVERAGE(1)					      General Commands Manual						PYTHON-COVERAGE(1)

NAME
python-coverage - measure code coverage of Python program execution SYNOPSIS
python-coverage -x module.py [ARG...] python-coverage -e python-coverage -r [-m] python-coverage -a [file...] DESCRIPTION
python-coverage executes a Python program and measures which of its statements are executed and which are not. It stores the information in the file .coverage in the current working directory. OPTIONS
-e Erase the .coverage file. -x Execute a Python module, giving it the remaining command line arguments. -r Produce a coverage report. -m With -r, show the line numbers that were missed by the execution. -a Annotate source files. For each source file foo, produce foo,cover, with executed lines prefixed by ">" and non-executed by "!". --help Produce a help summary. It might be more helpful than this manual page. AUTHOR
The python-coverage command is a one-line Python script which calls the coverage.py Python module to do all the work. The module was rigi- nally developed by Gareth Rees, and is now developed by Ned Batchelder. The module's home page is http://www.nedbatchelder.com/code/modules/coverage.html. This manual page was cobbled together by Lars Wirzenius for Debian, by copy-pasting from the help texts from the module. PYTHON-COVERAGE(1)