1.3.2-1: problem running Expect from JNI.

Vaughn Balchunas vbalchunas@doradosoftware.com
Wed Jul 18 16:19:00 GMT 2001


I have modified Mumit Khan's simple JNI example from
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/
to make a native Expect library call using JNI.
What I did was add a line to call the exp_popen() function from the Expect
library libexpect526.a. (installed with cygwin setup).
What is displayed on the console when running the java program is a java
usage message as if the command 'java' had been entered on the terminal. The
Expect library call exp_popen is a wrapper to Expect's spawn and I am asking
it to spawn an FTP session.

This is the output:

~/oware35/native/java-jni/c:java Main
Java JNI
HOME = /cygdrive/d/work
Usage: java [-options] class [args...]
           (to execute a class)
   or  java -jar [-options] jarfile [args...]
           (to execute a jar file)

where options include:
    -cp -classpath <directories and zip/jar files separated by ;>
                  set search path for application classes and resources
    -D<name>=<value>
                  set a system property
    -verbose[:class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -showversion  print product version and continue
    -? -help      print this help message
    -X            print help on non-standard options
      0 [main] java 200 sync_with_child: child 97(0x364) died before
initialization with status code 0x1
    298 [main] java 200 sync_with_child: *** child state waiting for longjmp
After native call

This is the JNI source:

#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include "HelloWorld.h"

#include "/usr/include/expect.h"

JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld (JNIEnv *env, jobject obj)
{
  char *home;
  printf("Java JNI\n");
  home = getenv ("HOME");
  printf("HOME = %s\n", (home) ? home : "(NULL)");

//      exp_popen("ls");
        exp_popen("ftp");

  return;
}

Attached is the makefile.


Finding a reliable NT port of Expect that I can call from java has been
difficult. If anyone has done this before or knows someone who can help me I
would appreciate it.


Vaughn Balchunas
Sr. Software Engineer
Dorado Software
www.doradosoftware.com
916-673-1104
vbalchunas@doradosoftware.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile.new
Type: text/x-makefile
Size: 2339 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20010718/41b084e7/attachment.bin>


More information about the Cygwin mailing list