|
1 | 1 | package com.genexus; |
2 | 2 |
|
3 | | -import java.io.File; |
4 | | -import java.io.IOException; |
5 | | -import java.io.UnsupportedEncodingException; |
| 3 | +import java.io.*; |
6 | 4 | import java.math.BigDecimal; |
7 | 5 | import java.nio.file.Paths; |
8 | 6 | import java.text.ParseException; |
9 | 7 | import java.text.SimpleDateFormat; |
10 | | -import java.util.Calendar; |
11 | | -import java.util.Date; |
12 | | -import java.util.Locale; |
13 | | -import java.util.Random; |
14 | | -import java.util.TimeZone; |
15 | | -import java.util.Vector; |
| 8 | +import java.util.*; |
16 | 9 |
|
17 | 10 | import com.genexus.common.interfaces.SpecificImplementation; |
18 | 11 | import com.genexus.internet.HttpContext; |
@@ -1103,31 +1096,27 @@ public static byte openPrintDocument(String document) |
1103 | 1096 | return (byte) NativeFunctions.getInstance().shellExecute(document, "print"); |
1104 | 1097 | } |
1105 | 1098 |
|
1106 | | - /** Hace un Shell modal. Ejecuta en la misma 'consola' que su parent |
1107 | | - * @param command Comando a ejecutar |
1108 | | - * @return true si el comando se pudo ejecutar |
1109 | | - */ |
1110 | | - public static boolean shellModal(String command) |
1111 | | - { |
1112 | | - return NativeFunctions.getInstance().executeModal(command, true); |
1113 | | - } |
1114 | | - |
1115 | 1099 | public static byte shell(String cmd, int modal) |
1116 | 1100 | { |
1117 | | - if (modal == 1) |
1118 | | - return shellModal(cmd)? 0 : (byte) 1; |
1119 | | - |
1120 | 1101 | try |
1121 | 1102 | { |
1122 | | - Runtime.getRuntime().exec(cmd); |
| 1103 | + List<String> al = Arrays.asList(cmd.split(" ")); |
| 1104 | + ProcessBuilder pb = new ProcessBuilder(al); |
| 1105 | + pb.redirectOutput(ProcessBuilder.Redirect.INHERIT); |
| 1106 | + pb.redirectError(ProcessBuilder.Redirect.INHERIT); |
| 1107 | + pb.redirectInput(ProcessBuilder.Redirect.INHERIT); |
| 1108 | + Process p = pb.start(); |
| 1109 | + |
| 1110 | + byte exitCode = (byte)p.waitFor(); |
| 1111 | + |
| 1112 | + p.destroy(); |
| 1113 | + return exitCode; |
1123 | 1114 | } |
1124 | 1115 | catch (Exception e) |
1125 | 1116 | { |
1126 | 1117 | System.err.println("e " + e); |
1127 | 1118 | return 1; |
1128 | 1119 | } |
1129 | | - |
1130 | | - return 0; |
1131 | 1120 | } |
1132 | 1121 |
|
1133 | 1122 | public static byte shell(String cmd) |
|
0 commit comments