473,385 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with writing an interface for system() call...

hi ..

I was reading the tutorial "Extending and Embedding
the python interpreter" available with python ..

http://www.python.org/doc/2.2.3/ext/ext.html

As per given in the tutorial i created an interface to
the system() system call.

this is the code of my module
Code:
#include<Python.h>

static PyObject * spam_system(self,args)
{
PyObject * self;
PyObject * args;
char * command;
int sts;

if ( !PyArg_ParseTuple(args, "s" , &command))
return NULL;

sts = system(command);
return Py_BuildValue("i",sts);
}

static PyMethodDef SpamMethods[] = {
{ "system", spam_system , METH_VARARGS,"Execute a
shell command"},
{NULL,NULL,0,NULL}
};

void initspam(void){
(void) Py_InitModule("spam", SpamMethods);
}
int main(int argc,char **argv)
{
// Py_SetProgName(argv[0]);

/* I COMMENTED THE ABOVE CALL AS IT GAVE ME SOME WIERD
ERROR */

Py_Initialize();

initspam();
}

i was able to compile the above code using disutils
package available with python .

http://www.python.org/doc/2.2.3/ext/building.html

I was even able to import the module into the python
interpreter but caling the function gave me the
following error
Code:
import spam
spam.system("ls -l")

python: Python/getargs.c:90: vgetargs1: Assertion
`compat || (args != (PyObject*)((void *)0))' failed.
Aborted
[haynes@fosters:~/python]
whaaaaattttt????

any idea?

thnks

Haynes Mathew
Send instant messages to your online friends http://in.messenger.yahoo.com
Jan 9 '06 #1
0 1242

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nadav | last post by:
Hi, Introduction: **************** I am writing a component based application, the application is built of several Native COM objects and some .NET classes exposed as COM objects by 'COM...
2
by: Jeff Van Epps | last post by:
We've been unable to get events working going from C# to VJ++. We think that the C# component is being exposed properly as a ConnectionPoint, and the Advise() from the VJ++ side seems to be...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
7
by: Desmond Cassidy | last post by:
Hi, I have being trying to get a grip of HTML data manipulation and am using the mshtml class and System.Net to retriver HTML pages. Now as far as I can see, one can read HTML in different ways....
10
by: Bryce Calhoun | last post by:
Hello, First of all, this is a .NET 1.1 component I'm creating. SUMMARY ----------------------- This component that I'm creating is, for all intents and purposes, a document parser (I'm...
0
by: Slawomir Nasiadka | last post by:
Hi, I'am new to this group so I would like to say "Hello" everyone and here is my problem: I'm writing a simple application (code is at the end of this message) witch would list all mails...
13
by: rkausch | last post by:
Hello everyone, I'm writing because I'm frustrated with the implementation of C#'s generics, and need a workaround. I come from a Java background, and am currently writing a portion of an...
0
by: krishnasamy | last post by:
Hello, I am writing a DLL for Capturing the Image from Camera Device using Camera SDK DLL. All the calls made to functions in Camera SDK DLL are working properly as I am able to get a return...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.