This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
1.3.2-1: problem running Expect from JNI.
- To: <cygwin at cygwin dot com>
- Subject: 1.3.2-1: problem running Expect from JNI.
- From: "Vaughn Balchunas" <vbalchunas at doradosoftware dot com>
- Date: Wed, 18 Jul 2001 16:23:04 -0700
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
Makefile.new
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/