elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Java
| | | |-+  Mantener CMD visible [leanlo, y entendereis xD]
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Mantener CMD visible [leanlo, y entendereis xD]  (Leído 3,298 veces)
zer01

Desconectado Desconectado

Mensajes: 6


Ver Perfil
Mantener CMD visible [leanlo, y entendereis xD]
« en: 29 Noviembre 2007, 22:17 pm »

Buenas,

Tengo un pequeño problema, estoy haciendo un programa que cuando abras el archivo .jar te hace una serie de preguntas, y luego abra el cmd.exe y escriba un comando.

Todo hasta ahi bien, incluso escribe el comando perfectamente. El unico problema, esque la ventana del CMD queda invisible y solo la puedes cerrar atraves del taskmgr.

Entonces mi pregunta es, si una vez escrito este comando en el cmd, la ventana podria APARECER.

Código:
try {
           
            Process p = Runtime.getRuntime().exec("ping -t 127.0.0.1");
           
            BufferedReader stdInput = new BufferedReader(new
                    InputStreamReader(p.getInputStream()));
           
            BufferedReader stdError = new BufferedReader(new
                    InputStreamReader(p.getErrorStream()));
           
            // read the output from the command
           
            System.out.println("Here is the standard output of the command:\n");
            while ((s = stdInput.readLine()) != null) {
                System.out.println(s);
            }
           
            // read any errors from the attempted command
           
            System.out.println("Here is the standard error of the command (if any):\n");
            while ((s = stdError.readLine()) != null) {
                System.out.println(s);
            }
           
            System.exit(0);
        } catch (IOException e) {
            System.out.println("exception happened - here's what I know: ");
            e.printStackTrace();
            System.exit(-1);
        }

Porque digamos, que si estoy haciendo un ping -t al localhost hasta que se "muera" me gustaria ver que esta pasando, y no se quedase silencioso.

Gracias :x


En línea

Casidiablo
Desarrollador
Colaborador
***
Desconectado Desconectado

Mensajes: 2.919



Ver Perfil WWW
Re: Mantener CMD visible [leanlo, y entendereis xD]
« Respuesta #1 en: 30 Noviembre 2007, 15:09 pm »

Intenta así:

Código:
try {
           
            Process p = Runtime.getRuntime().exec("cmd /C ping -t 127.0.0.1");
           
            BufferedReader stdInput = new BufferedReader(new
                    InputStreamReader(p.getInputStream()));
           
            BufferedReader stdError = new BufferedReader(new
                    InputStreamReader(p.getErrorStream()));
           
            // read the output from the command
           
            System.out.println("Here is the standard output of the command:\n");
            while ((s = stdInput.readLine()) != null) {
                System.out.println(s);
            }
           
            // read any errors from the attempted command
           
            System.out.println("Here is the standard error of the command (if any):\n");
            while ((s = stdError.readLine()) != null) {
                System.out.println(s);
            }
           
            System.exit(0);
        } catch (IOException e) {
            System.out.println("exception happened - here's what I know: ");
            e.printStackTrace();
            System.exit(-1);
        }

Pero ten en cuenta esto impide la posibilidad de portabilidad :( aunque se puede arreglar con unos ajustes.

Un saludo!


En línea

egyware


Desconectado Desconectado

Mensajes: 526



Ver Perfil WWW
Re: Mantener CMD visible [leanlo, y entendereis xD]
« Respuesta #2 en: 12 Diciembre 2007, 15:26 pm »


Pero ten en cuenta esto impide la posibilidad de portabilidad :( aunque se puede arreglar con unos ajustes.


Eso se puede arreglar usando las propiedades que te entrega System (os.name)
usando un String al comando a llamar por ejemplo si es windows usas cmd o linux usas bash

y esop un aporte sin gracia
por parte mia  :-X :-\ :-[
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Ayuda con equipo no visible en red
Redes
cassiiopeauah 1 3,524 Último mensaje 13 Abril 2011, 23:23 pm
por madpitbull_99
Hacer visible DataGridView asp.net
.NET (C#, VB.NET, ASP)
k4rn13l 0 1,668 Último mensaje 21 Diciembre 2011, 15:53 pm
por k4rn13l
JAVA 3D: ¿cómo mantener un text2d siempre visible al rotar una escena grafica?
Java
mikelonix 0 1,325 Último mensaje 25 Junio 2014, 12:27 pm
por mikelonix
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines