Need simple class for communicating with Solaris account
Hey, gang. After over a week of searching this forum and the Web for a solution, I'm stuck. I hope someone here can help.
I've got a Java application intended to run on both Windows and Solaris systems that needs to perform the following automated operations:
1. Connect to a user account on a Solaris server.
2. Login.
3. Run an sccs command.
4. Retrieve the output from the sccs command.
I can run commands (such as sccs) directly from Java; I've worked out how to do that. My situation is that I need to run sccs from an authorized account so that all file checkin/checkout operations are tagged properly. So the requirement to connect to a server isn't one I can ignore. I also don't need a full-up interactive client interface -- this needs to be an automated process.
What I'm hoping is that someone here will be willing to provide (or point me to) some relatively simple source code I can call to do this stuff. Maybe an example of a class that uses Socket and a couple of streams to programmatically connect to a server, send commands, and capture input. That's really all I need.
I've tried calling the Jakarta Commons telnet class to connect to the Solaris server, but it's more overhead than I need. (Plus the input stream kept blocking when I tried to use it in a purely automated mode.) I've also tried rolling my own code using the minimal info available on Google, but have not been able to figure out the magic words necessary to get anything back but gibberish. (InputStream and BufferedReader just do not seem to want to cooperate. Either I get back only garbage text, or readLine() or read() gets nothing and just sits and waits until the timeout.)
So I turn to the experts here. If anyone can offer (or direct me to) any simple, non-libraried source code that enables my Java code to connect to and talk to a Solaris machine, I'd be grateful.
Thanks!
i wrote something a while ago to connect to solaris and run a command. i used ssh java libs to do it. i would ssh in using my username, execute a command and pipe in the command's output. can you use ssh?
Hi, mkoryak -- thanks for the swift response.
It doesn't look like SSH is an option; it doesn't seem to be installed locally.
The good news (?) is that all the boxes here are part of an intranet. So I shouldn't need anything as burly as a SSH or telnet library -- a simple class to connect, write, and read should be good enough.
Anything like that out there?
Thanks!
errr,
what do you mean by connect if you dont mean ssh or telnet?
usually ssh isnt installed locally, if you are on windows, but it is almost always running on solaris/unix.
so unless you explain to me what you mean by connecting then i suggest you look into ssh clients.
it looks like the ssh library that i used is called:
ganymed-ssh2-build209.jar
if by "connect" you mean that you only need to access the disks, then you need to figure out how to read them through windows, mount them as a drive, and then access them like that.
if mounting is not an option, you will need to find a good java SMB library to connect to those drives, provided that you are running samba to share the drives to windowses
The code for the telnet clients I've looked at seems to be complex wrappers for the Java Socket class.
So what I think I'm looking for is source code for a simple class based on using Sockets that enables connection to a remote system and reading from/writing to that system while the connection is active, but that doesn't implement the additional details of telnet or SSH interfaces that I just don't need.
But maybe I'm missing something, and such interfaces are required. I've been programming for some years now, but I'm still new to this particular area -- if there's something I'm just not getting about what different boxes have to do to talk to each other, I'm open to being educated.
Thanks!
> The code for the telnet clients I've looked at seems
> to be complex wrappers for the Java Socket class.
>
> So what I think I'm looking for is source code for a
> simple class based on using Sockets that enables
> connection to a remote system and reading
> from/writing to that system while the connection is
> active, but that doesn't implement the additional
> details of telnet or SSH interfaces that I just don't
> need.
Then you will need a corresponding simplified service running on the server with which to communicate - is that in your plan?
>
> But maybe I'm missing something, and such interfaces
> are required. I've been programming for some years
> now, but I'm still new to this particular area -- if
> there's something I'm just not getting about what
> different boxes have to do to talk to each other, I'm
> open to being educated.
>
> Thanks!
I was hoping a separate server-side process wouldn't be needed -- if you're thinking of something like RMI, that's also a bit heavyweight for my needs. I know I can talk to the remote server on telnet port 23, though.
Further experimentation today with the Jakarta net library has generated something that works using their telnet classes. (After I asked for help here, of course. The same thing happens when I shop for groceries....) But using this leaves me referencing an external library that:
1. has functionality I don't need that complicates the code, and
2. forces me to address licensing requirements.
So I'd still love to see an example of a telnet-like Java class that strips away all the non-essentials in the Jakarta telnet library code, leaving behind a simple public domain class that can be used to connect to a remote host and transfer characters over that connection.
I appreciate that this may be asking for a lot, but as they say, if you don't ask, you don't get. ;-)
Thanks!
> I was hoping a separate server-side process wouldn't
> be needed -- if you're thinking of something like
> RMI, that's also a bit heavyweight for my needs. I
> know I can talk to the remote server on telnet port
> 23, though.
>
Yes, but if you're going to talk to a telnet server you will need to do so using a telnet client. If you don't want to talk telnet then you will need to talk some other protocol, which would require a server process which understood that protocol.
I may be failing to understand exactly what you want though, 'cause it's not making a lot of sense to me (but then, I can be a bit thick)
Good Luck
Lee
Nope, it was me. It looks like what I'm really needing is an actual telnet class provided as public domain source code.
It doesn't need any bells and whistles; just enough to support connecting to a host and sending and receiving characters would be great.
If anything like that exists, I'd really appreciate a pointer to it.
(Incidentally, this all comes about from my recoding an unmaintainable collection of Perl scripts into Java. The problem here is that the Perl code used a Telnet module, but Java doesn't offer similar functionality built into J2SE. It's possible that Java shouldn't offer its own Telnet class, but my life sure would have been easier this past week if it did.)
Hi,I am also looking for a java class to connect to a remote machine(Linux server) using ssh and execute a Shell Script which will have a series of Prompts(questions) for which I have to supply the values programmatically. Thanks for your help!Siva