So I have a shell script which when executed an executable will display lines as wide as your terminal width. When I execute the script using ProcessBuilder it automatically returns only the first 80 characters. I've tried a variety of things, like adding stty rows 50 cols 132 to the script, or trying to set some environment variables in ProcessBuilder but can't find a way to change the terminal width of the process. Running this on RHEL.
ProcessBuilder p = new ProcessBuilder(new String[] {"/bin/ksh",
"myscript.ksh"});
BufferedReader br = new BufferedReader(new InputStreamReader(p2.getInputStream()));
String line;
StringBuffer output = new StringBuffer();
while ((line = br.readLine()) != null) {
System.out.println(line);
}
The terminal width is determined by the terminal program your using. Each terminal program has you set the width a different way (usually in the settings somewhere). If they respond to any sort of global variable or command sequence then it may be different for each terminal program (and some dont have this feature). However there is a standard solution that some terminal programs have adopted.
Only way would be to find a terminal program that does respond to a specific global variable or command sequence and force your user to invoke the application using that particularly terminal program.
The closest solution there is to a standard would be the following control sequence which will resize certain terminal emulators:
System.out.println("\e[8;50;100t")
The above will resize your terminal to 100x50
However the above will not work with all terminal emulators there are several that will recognize it. Just need to ensure the user is using a terminal program that supports the standard.
See XTerm Control Sequences reference for more information.