Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Another Java Question
Good Morning.
I am trying to get the output of a server process executed by java via Runtime.exec(). Here's the code:
import java.sql.*;
import java.io.*;
public class ip {
public static void main (String args []) {
Runtime r = Runtime.getRuntime();
try {
String sid = "emsd"; String cmd1 = "tnsping " + sid + " | grep 'Host' | cut -d' ' -f18 | cut -d')' -f1"; System.out.println(cmd1); Process p = Runtime.getRuntime().exec(cmd1); int exitValue = p.waitFor(); System.out.println(p); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String ip = br.readLine(); System.out.println(ip); } catch (Exception e) { System.out.println("Generic Exception catch.");}
When I execute it I get:
tnsping emsd | grep 'Host' | cut -d' ' -f18 | cut -d')' -f1
java.lang.UNIXProcess_at_5988f
The output of the command line is:
128.100.1.140
Anyone see what I'm missing?
Just to make this somewhat oracle related...this is part of a hot backup
script.
I am trying to grep the ip (and ultimately port) of the listener so I can
dynamically generate the connect to the database. :)
Thanks,
John P Weatherman
Database Administrator
Replacements Ltd.
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: John Weatherman
INET: john.weatherman_at_replacements.com
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Mon Dec 09 2002 - 10:28:44 CST
![]() |
![]() |