Is there a way to run a Linux shell script from a java program if they
are on different machines?  I'm trying to write a Java program that will
run on a Windows machine, connect to a Linux machine, and run a Linux
shell script.  Is that possible?  Can anyone provide an example of how
you would write such a program?  I wrote a program that supposedly
connects to the Linux machine from my Windows, but it does not run the
shell script.  Can anyone see what is wrong?  I get all the messages
indicating that it ran but the output from hello.sh is not being
generated.  Thanks in advance.

import java.io.*;
import java.net.*;

class Client
{
  public static void main(String[] arg)
  {
    Socket s = null; // set up socket
    BufferedReader is = null;  // input stream
    PrintWriter os=null;  // output stream

    try
    {
      System.out.println( "Settting up Socket" );
      s = new Socket("10.1.1.200",23,true);

      System.out.println( "Setting up Input Stream" );
      is = new BufferedReader(new InputStreamReader(
s.getInputStream()));

      System.out.println( "Setting up Output Stream" );
      os = new PrintWriter(s.getOutputStream(), true);
    }
    catch(UnknownHostException uhe )
    {
      System.out.println( "I don't know the host" );
    }
    catch (Exception e)
    {
      System.out.println(e);
    }

    BufferedReader stdIn=new BufferedReader(new
InputStreamReader(System.in));
     String userInput;

    if( s != null && is != null && os != null )
    {
      try
      {
        System.out.println( "Sending command" );
        String command = ("/home/hello.sh");
        os.println(command);
        System.out.println( "Closing Output Stream" );
        os.close();
        System.out.println( "Closing Input Stream" );
        is.close();
      }
      catch(UnknownHostException uhe )
      {
        System.out.println( "I don't know the host" );
      }
      catch(IOException ie)
      {
        System.out.println(ie);
      }
      catch (Exception e)
      {
        System.out.println(e);
      }
    } // end if
  } // end main
} // end Client



begin:vcard 
n:Gfell;Natasha
tel;fax:216 - 641 - 0882
tel;work:216 - 641 - 4000 Ext. 162
x-mozilla-html:TRUE
url:www.clevelandtrack.com
org:CTM Bessemer;MIS
adr:;;6917 Bessemer Ave;Cleveland;Oh;44127;United States
version:2.1
email;internet:[EMAIL PROTECTED]
title:programmer
fn:Natasha Gfell
end:vcard

Reply via email to