Harri Sunila writes:
> On Tue, 17 Aug 1999, Amlan Saha wrote:
>
> > Hi there
> >
> > I am trying to write a Java wrapper for some C libraries. I have
> > gotten most of it working except that I am not able to launch
> > programs from the C libaries. I have a standard C-shared object
> > library where I define a function using
> >
> > JNIEXPORT int JNICALL Java_API_Mypackage_myfunction
> > (JNIEnv *env, jobject theObj)
> > {
> > fprintf(stdout,"Entered myfunction ...");
> > execv("/sbin/ifconfig",NULL);
> > return(errno);
> > }
> >
> > which I then call from my java program by -
> > API.Mypackage n = new API.Mypackage();
> > int ret = n.myfunction();
> > System.out.println(ret);
> >
> > However, this method does not result in printing out the ethernet
> > interface information as it should if the program had executed the
> > "/sbin/ifconfig" program. It just prints till the "Entered
> > myfunction..." part and then exits. ERRNO reports "number 2" which
> > is "no such file or directory" while I KNOW that it is there.
> >
> > This is what I get -
> >
> > [amlan@catbert jwrapper]$ java TestTheWrapper
> > Entered myfunction...
> > 2
> > [amlan@catbert jwrapper]$
> >
> > What am I doing wrong ??
>
> As Linux Programmer's Manual says the syntax of execv() is:
>
> 'int execv( const char *path, char *const argv[]);'
>
> You should give "/sbin" as the first argument of execv() and "ifconfig" as
> argv[0] or use execvp() instead of execv() and probably give "ifconfig" as
> argv[0]. As you should know, in C argv[0] is the name of the executed
> program and the rest of argv[] are the arguments for the program. Try 'man
> execv' for further details.
>
Harri
Thanks for the prompt reply.
OK, tried that, however to no avail. Has it got something to do
with the java layer on top ? At least the simple
system("/bin/ifconfig");
should work right ?
-amlan.
--
Amlan Saha [EMAIL PROTECTED]
[EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]