Skip to main content

Posts

Showing posts from May, 2005

Capture the output from Java Runtime.getRuntime().exec()

By using Java Runtime.getRuntime().exec(), you can start an external binary from JRE. If there are some outputs or errors and you don't handle them, you will face some potential problems such as buffer overflow and don't have a clue where to debug. The following class can be used to catch/process the outputs from Runtime.getRuntime().exec() class StreamReader extends Thread { Reader input; int c; char[] chars = new char[1000]; String line; String threadName; public StreamReader(String threadName, Reader input) { this.input = input; this.threadName = threadName; } public void run() { try { while ((c = input.read(chars)) != -1) { line = new String(chars, 0, c); System.out.print(threadName + " " + line); } } catch (Exception e) { System.out.println(e.getMessage()); } } } When you start the process, you can call with Process p...

Install Windows XP and Fedora Core 3 Dual Boot on Dell Inspiron 8600

1. Partition. The Dell Inspiron 8600 comes with a whole C:. Even if you just want to use Windows system, it is a bad idea to put everything in one logical disk. You can use some partition tools to partition hard disk while keeping all the installed software, such as PowerQuest's PartitionMagic or Paragon's Partition Commander . I use PartitionMagic split the disk and reserve ~10G for Fedora Core 3 installation. Here is the example of what the final partition table looks like: (/dev/hda4 is extended partition that /dev/hda5 above sits) > fdisk -l Device Boot Start End Blocks Id System Comment /dev/hda1 1 261 2096451 de Dell Utility Dell pre-installed POST /dev/hda2 * 262 6277 48323520 7 HPFS/NTFS Windows XP Professional /dev/hda3 6278 ...

SSH Tunneling Mail Relay Setup

When you on the travel or other cases, you may not be able to send out email because of the Mail Server deny the relay. Here is a solution. Step 1: Download and install SSH Client. Step 2: Setup outgoing tunneling in SSH Client. For example, creating an outgoing tunneling named smtp that listens on local port 2525 with localhost as destination host and 25 as destination port. Step 3: In Mail Client, specify the SMTP server as localhost with port 2525 . Step 4: SSH to a server in the same domain as your SMTP server.

Setup CVS SSH Access and Eclipse CVS Perspective

Notation: [s] - server side where SSH and CVS demons running [c] - client side to access CVS through SSH 1. Generate SSH authentication key [c] ssh-genkey -t rsa Follow the prompt steps, it will create private key id_rsa and publice key id_rsa.pub under ~/.ssh. It is a good practice to have passphrase for the key. * Windows users can get ssh from www.ssh.com . 2. SSH key-based Authentication Copy id_rsa.pub to server. [s] modify /etc/ssh/sshd_config as necessary. Take a note on AuthorizedKeysFile and AllowUsers lines. For example: AuthorizedKeysFile authorized_keys2 AllowUsers tom@x.x.x.x;jerry [s] cat id_rsa.pub >> authorized_keys2 [s] /etc/init.d/sshd restart Now you should be able to ssh login from client to server without any passport prompt. 3. Config CVS SSH access [c] cat ~/.bashrc, and add lines as below: CVSROOT=:ext:login@remote_cvs_server:/usr/local/cvsroot CVS_RSH=ssh export CVSROOT export CVS_RSH * Windows users can setup them in C...