• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Needs to connect unix box from JAVA

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I'm doing one project, where I've one requirement like this.
( Needs to connect unixbox from JAVA)

1) I've to read one particular file from Unix box(using putty) and content of that file needs to print in java console.

Please help me with this ASAP!!!
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sudharsan raghav wrote:1) I've to read one particular file from Unix box(using putty) and content of that file needs to print in java console.


You'll need an SSH library, like JSch, to connect to the UNIX machine using the SSH protocol (which is what you use PuTTY for as well).

Please help me with this ASAP!!!


Please EaseUp
 
sudharsan raghav
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes... I've completed the above mentioned task. Now I need another code where my the values of that unix file will be printed in one jsp page. That JSP page needs to refreshed for every 5 minutes which results in the execution of my java code for every 5 mins to get the latest value of the file from the unix server( Note : the file I'm taking from the unix server is a script file which runs for every 5 mins and change the values).

please help immediately!!!
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sudharsan raghav wrote:yes... I've completed the above mentioned task. Now I need another code where my the values of that unix file will be printed in one jsp page.


Well, you know how to read the file, it should then be easily to print it, shouldn't it?

That JSP page needs to refreshed for every 5 minutes which results in the execution of my java code for every 5 mins to get the latest value of the file from the unix server( Note : the file I'm taking from the unix server is a script file which runs for every 5 mins and change the values).


You'll need to do this in HTML code; either using JavaScript or the easy way using a META tag:


please help immediately!!!


I told you before to EaseUp. Once more and this thread is closed.
 
sudharsan raghav
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,

I've connected unix box with this code : Using enchanter jar

import java.util.*;
public class MainSSH {

/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {

SSH ssh = new DefaultSSH();
String line =null;
List ss = new ArrayList();


ssh.connect("", 22, "ddd", "");
ssh.waitFor("]$");
ssh.sendLine("cd ");
ssh.sendLine("ls omg.bmp");
ssh.sendLine("tail omg.bmp");
System.out.println(ssh.getLine());
ssh.disconnect();
}
}

With this code I can connect to the unix box but what I need to do is, I've to print the contents present in the "omg.bmp" after the tail command.. So Is there any way to print all the lines of the tail command in java. Please help me with this immediately. As I'm new to java, I'm not able to proceed with this.. Your help is really appreciated.
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I checked Enchanter briefly but it appears it cannot handle file transfers, only commands. If you want to transfer binary data simple SSH commands will not work; you will really need to use SCP (the file transfer protocol of SSH). I couldn't find anything like that in Enchanter (again, only checked briefly). Perhaps you need a different library (I again mention JSch).
 
sudharsan raghav
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,

Everything is working fine.. I've one small doubt, When Executing this program via., Myeclipse I'm getting "heap space memory error". Please help me soon.

Thanks in advance.

Sudharsan.t
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sudharsan raghav wrote:soon.


Please EaseUp.

For a reason unknown to use your Java program is using a lot of memory. The default upper limit of the JVM is about 64MB. You have two options:
1) identify what is causing the huge memory footprint and fix the issue at the source, or
2) use the -Xmx flag to specify a higher upper limit for the JVM. How you do that in your IDE I can't tell you.
 
sudharsan raghav
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using myeclipse6.5 version. please help me how to do that.


thanks,
sudharsan.t
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic