Attached are two programs. Compile the C program and the java program. Then run the java program with the C program as the argument. This causes the java program to exec the C program. The user input is then fed to the C program But it never gets to the C program for some reason. Your help would be appreciated.
Rohit
/**************************************************************************/
/*------ test.c ------ C program --- simple program to print uppercase letters to lowercase*/
/**************************************************************************/
#include <stdio.h>
#include <ctype.h>
main() {
 int c;
	while((c = getchar()) != EOF) {
	    putchar(tolower(c));
}
return 0;
}
/**************************************************************************/
/*---- TestExec.java ---  Java program  for execing C program*/
/* Usage java TestExec c_program_name */
/**************************************************************************/
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
public class TestExec {
	
	public static void main(String argv[]) {
		Runtime rt = Runtime.getRuntime();
		Process proc = null;
		BufferedReader in = null;
		//DataOutputStream out = null;
		PrintWriter out = null;
		try {
			proc = rt.exec(argv);
			if (null == proc) {
				System.out.println("Process exec fails");
				System.exit(1);
			}
			in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
			out = new PrintWriter(proc.getOutputStream());
			if (null == in) {
				System.out.println("Input Stream is null");
				System.exit(1);
			}
			if (null == out) {
				System.out.println("Output Stream is null");
				System.exit(1);
			}
		}
		catch (IOException e) {
			System.out.println("Process exec fails: " + e.getMessage());
			System.exit(1);
		}
		String inputStr = null;
		String outputStr = null;
		DataInputStream systemIn = new DataInputStream(System.in);
		System.out.print("Input: ");
		try {
		inputStr = systemIn.readLine();
		while (! inputStr.equals("quit")) {
			out.println(inputStr);
			out.flush();
			outputStr = in.readLine();
			System.out.println("Output: " + outputStr);
			System.out.print("Input: ");
			inputStr = systemIn.readLine();
		}
		}
		catch (IOException ie) {
			System.out.println("Interaction Error: " + ie.getMessage());
		}
		System.out.println("Viola!");
	}
}
rohit.valia@Eng 1997-06-09