Getting LINES/COLUMNS example in C using curses library:
#include <stdio.h>
#include <curses.h>
int main() {
int max_x, max_y;
initscr();
getmaxyx(stdscr, max_y, max_x);
endwin();
if (max_x == -1) {
fprintf(stderr, "getmaxyx() failed\n");
return 1;
}
printf("COLUMNS=%d; LINES=%d\n", (max_x - 1), (max_y - 1));
}
Compiling:
size_curses: size_curses.c
gcc -o size_curses -lcurses size_curses.c
Same using Python:
#!/usr/bin/python3
import curses
try:
stdscr = curses.initscr()
height, width = stdscr.getmaxyx()
finally:
curses.endwin()
if height == -1:
print("getmaxyx() failed!")
else:
print("COLUMNS=%d; LINES=%d" % (width, height))
Python is now part of VIOS 4.1. If you put the python script into /usr/ios/cli/utils, you can call it from your padmin interface:
$ ioslevel
4.1.0.10
$ who am i
padmin pts/1 Mar 13 05:08 (10.X.X.X)
$ resize
COLUMNS=141; LINES=39
------------------------------
Andrey Klyachkin
https://www.power-devops.com------------------------------
Original Message:
Sent: Wed March 13, 2024 03:03 AM
From: FREDRIK LUNDHOLM
Subject: VIOS 4.1.0.10 /usr/X11R7/bin/resize command is gone
I uploaded the source code (16 kB, msotly comments) for resize as shipped with the xterm package.
(See attachement)
It used the following X11 functions (probably because xterm written before libc standardized between Unixes).
x_basename
x_getenv
x_getpwuid
x_getlogin
x_strdup
x_basename
x_strindex
As expected the majority of code is written to calculate the current window size.
It should be utterly trivial to substitute with modern equvilents and remove and X11 dependency,
Have a look and suggest if resize.c does anything better compared to the alias/scrips
suggeted above.
------------------------------
FREDRIK LUNDHOLM
Original Message:
Sent: Tue March 12, 2024 11:22 AM
From: Lance Hawkes
Subject: VIOS 4.1.0.10 /usr/X11R7/bin/resize command is gone
Great suggestions! I will play around with it a bit and see what I like the best.
------------------------------
Lance Hawkes
Original Message:
Sent: Tue March 12, 2024 11:06 AM
From: GEERT OOST
Subject: VIOS 4.1.0.10 /usr/X11R7/bin/resize command is gone
Indeed as part of the new Rebase of VIOS several filesets were removed that weren't really used in the first place both to reduce the overall
mksysb image of the VIOS and because several security scanning tools could be triggered by "unsafe" filesets.
The resize binary indeed needs several X11 related libraries but I guess the function could also just be replicated by a ksh script as well ?
$ cat resize.sh
#!/bin/ksh93
# Get the number of lines and columns
stty size | read lines cols
# Print the results
echo "COLUMNS=$cols;"
echo "LINES=$lines;"
echo "export COLUMNS LINES;"
------------------------------
GEERT OOST
Original Message:
Sent: Fri March 08, 2024 12:06 AM
From: Lance Hawkes
Subject: VIOS 4.1.0.10 /usr/X11R7/bin/resize command is gone
I recently installed some new 4.1.0.10 VIO servers. During the configuration, I'm using vtmenu from the HMC to open a console to the VIO server. Because I don't like the small terminal window, I typically resize my PuTTY or iTerm2 or MobaXterm session and run /usr/X11R7/bin/resize to scale my terminal window to the new window size. Well, in 4.1.0.10, that command no longer exists. Any suggestions about how I can resize my terminal to the new window size?
Thanks in advance,
Lance
------------------------------
Lance Hawkes
------------------------------