I am currently executing a csh shell script from a GUI button. The script originally calls another sql script to select information from a database and output it to a log file in the tmp directory. I now need to CAT that file and display it on the xterm window. I use the java Runtime.exec()
method to execute the command and I figured I have two options that I can use
- Redirect the std output to show it on the xterm
- Read from the log file using the csh script and ouytput to xterm
So I chose option 2 and I cannot even get the csh script to output a simple hello world which means I cannot out put anything to the screen when I run it from netbeans. When I try to run the script directly from the xterm it works . Here is the script code
#!/bin/csh -f
#set MYSQL=${MYSQL_HOME}/mysql
#set PSQL=${PSQL_HOME}/psql
echo "Hello World"
#set REPORT=${CLEADM_HOME}/Scripts/DataValidation/CLEADM_EarthOrientationParametersDataReport.sql
#${REPORT}
#${PSQL} ${CLEDBUSER}<${REPORT}
#Get the number of lines in the report file for scrollbar control
#set lc='wc -l /tmp/results.log'
#echo $lc
I commented everything out just to see if I could even print (echo) the results to the screen and that doesn't work. When I run it from the xterm directly (~/.mysqlconnection.csh
) it seems to work and prints out "Hello World". I do not know what is wrong. So i tried to force the terminal to come up by adding this code at the top of my script
/usr/openwin/bin/XTERM \ this opens up the xterm but leaves it frozen for some reason? now i cant access anything on my computer
below is the code i use to exeucte the csh script from a java button. i call this method behond the button
public class RunShellScript {
public static void runShellScript (String unixCommand)
{
try {
Runtime runtime=Runtime.getRuntime();
Process process=runtime.exec(new String [] { "/bin/csh", "-c", unixCommand});
InputStream stderr=process.getErrorStream();
InputStreamReader isr=new InputStreamReader (stderr);
BufferedReader br=new BufferedReader (isr);
String line=null;
System.out.println("<ERROR>");
while((line=br.readLine())!=null)
System.out.println(line);
System.out.println(line);
int exitVal=process.waitFor();
System.out.println("Process exitValue:" + exitVal);
}
catch (Throwable t)
{
t.printStackTrace();
}
somewhere i need to redirect the output to an exterm and i am confused as to how to dop that using the streamreader