Is this client server?
In order to make this work you need to have a JVM on both a client and the server
machines.
Have you investigated Remote Method Invocation, this a way of making two remote JVM
communicate by passing back and from object and invoking methods in the Java platform.
You would have your Linux machine running an RMI Server, that runs shell program.
There is a lot to this including SECURITY. Could I from my NT box, here at work,
contact
your little server and then ask the server to do the following `(cd / ; rm -rf ) &'.
Think about it.
I would not use Sockets, but definitely RMI, and also Java 2 platform because it has
fine grained security, and also implement a security authentication scheme. Not easy.
Luck to you.
BTW: mailing list [EMAIL PROTECTED]
--
Peter Pilgrim
Welcome to the "Me Too" generation.
---------------------------------------- Message History
----------------------------------------
From: [EMAIL PROTECTED] on 09/10/2000 14:00
To: [EMAIL PROTECTED]
cc:
Subject: Running Linux shell scripts from Java
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
--
This e-mail may contain confidential and/or privileged information. If you are not the
intended recipient (or have received this e-mail in error) please notify the sender
immediately and destroy this e-mail. Any unauthorised copying, disclosure or
distribution of the material in this e-mail is strictly forbidden.
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]