xterm - What configuration controls # of windows - xterm

I'm using a xterm session I inherited, but every time I start it, it opens 4 windows. I'd prefer to open 1 or 2 windows. does anyone know the command line argument that affects the number of windows that start up? I thought it was the XTerm*font1-4 configuration, but that doesn't seem to be the case.
Would it be the in the startup command argoument I'm using or the .Xsession config file?
/usr/bin/xterm -ls -tn xterms -sb -display #d

It's in your .Xsession (or .xinitrc) file. xterm creates only one window. If you have four windows, that's four times xterm was executed in the initialization script, e.g.,
xterm &
xterm &
xterm &
xterm

Related

Create a script to open multiple terminal windows with some commands on Ubuntu

I want to create a script to open multiple terminals and each terminal calls a different command. For example one terminal calls dmesg and a few other terminals call another command. I also want to specify the size of the terminal window. (ie. the terminal displaying dmesg is on the left, the next one is next to the dmesg terminal and so fourth)
The example screenshot is below.
Thanks,
You can use
gnome-terminal --geometry=GEOMETRY1 -- PROGRAM1 [ARG1...] &
gnome-terminal --geometry=GEOMETRY2 -- PROGRAM2 [ARG2...] &
gnome-terminal --geometry=GEOMETRY3 -- PROGRAM3 [ARG3...] &
see https://manpages.ubuntu.com/manpages/bionic/man1/gnome-terminal.1.html for details

Open a Graphical Window that uses Ncurses

Let's say I'm running xterm or some other terminal emulator on top of some graphical X Window Environment. xterm on KDE, for example. I want to write an application that may be called on the command line of one terminal emulator, and upon execution, the application creates a new KDE/Environment window, separate from the current terminal emulator, and on that new window run an Ncurses context for application purposes.
How would I do this? Is this terminal emulator dependent? Desktop environment dependent? Would I be using bare X window system calls?
It's terminal (emulator) dependent.
Curses runs in terminals and terminal emulators. Most of the latter (terminal emulators) have some way to tell what program (other than your shell) to run in the terminal emulator.
For instance, xterm can be told using the -e option,
-e program [ arguments ... ]
This option specifies the program (and its command line
arguments) to be run in the xterm window. It also sets the
window title and icon name to be the basename of the program
being executed if neither -T nor -n are given on the command
line.
NOTE: This must be the last option on the command line.
letting you start an xterm running MyApplication like this:
xterm -e MyApplication
Again, most of the terminal emulators you might run in X accept that option. KDE konsole does that. There's no manual, but
konsole --help-all
shows it at the end.

How to create a shell script to launch 3 terminals and execute a set of commands in each?

Currently, I open 3 terminals ('openocd session','telnet session' & 'gdb session') and execute 'a set of commands' in each terminal every time I flash my image on target.
Is is possible to put this in one shell script file and run at once? (Commands on each terminal are NOT dependent on others; except that the terminals should be opened in the order mentioned above)
Thanks in advance !
Which terminal are you using?
A terminal like xterm can start a program instead of a shell. Simply run
xterm -e 'command args ...'
I use this to start my email client:
xterm -e mutt
If you use a different terminal, consult its manual page. I'm pretty sure there's an equivalent for -e.

Linux equivalent of the DOS "start" command?

I'm writing a ksh script and I have to run a executable at a separate Command Prompt window.
xdg-open is a similar command line app in linux.
see https://superuser.com/questions/38984/linux-equivalent-command-for-open-command-on-mac-windows for details on its use.
I believe you mean something like xterm -e your.sh &
Don't forget the final &
maybe it´s not a seperate window that gets started, but you can run some executables in background using "&"
e.g.
./myexecutable &
means your script will not wait until myexecutable has finished but goes on immediately. maybe this is what you are looking for.
regards
xdg-open is a good equivalent for the MS windows commandline start command:
xdg-open file
opens that file or url with its default application
xdg-open .
opens the currect folder in the default file manager
One of the most useful terminal session programs is screen.
screen -dmS title executable
You can list all your screen sessions by running
screen -ls
And you can connect to your created screen session (also allowing multiple simultaneous/synchronized sessions) by running
screen -x title
This will open up the emulated terminal in the current window where executable is running. You can detach a screen session by pressing C-a C-d, and can reattach as many times as you wish.
If you really want your program started in a new terminal window, you could do something like this:
xterm yourtextmodeprogram
or
gnome-terminal -e yourtextmodeprogram
or
konsole -e mc
Trouble is that you cannot count on a particular terminal emulator being installed, so (again: if you really want to do this) you would need to look for the common ones and then execute the first one encountered.
As Joachim mentioned: The normal way to do this is to background the command (read about shell job control somewhere, if you want to dig deeper).
There are also cases where you want to start a persistent shell, i.e. a shell session which lives on when you close the terminal window. There are two ways to do this:
batch-oriented: nohup command-to-run &
interactive: screen
if you want a new windows, just start a new instance of your terminal application: in kde it's
konsole -e whatever
i'm sure the Gnome terminal has similar options
Some have recommended starting it in the background with &, but beware that that will still send all console output from the application you launch to the terminal you launched it from. Additionally, if you close the initial terminal the program you loaded will end.
If you're using a desktop environment like KDE or GNOME, I'd check the alt+f2 launching apps (gnome-open is the one for GNOME, I don't know the name of the KDE app) and see if you can pass them the command to launch as an argument.
Also, if your intention is to launch a daemon, you should check the nohup documentation.
I used nohup as the following command and it works:
nohup <your command> &
then press enter and enter!
don't forget the last &
for example, I ran a python code listening to port 5000:
nohup python3 -W ignore mycode.py &
then I made sure of running by netstat -tulnp | grep :5000 and it was ok.

How do I autorun an application in a terminal in Ubuntu?

I've created a few autorun script files on various USB devices that run bash scripts when they mount. These scripts run "in the background", how do I get them to run in a terminal window? (Like the "Application in Terminal" gnome Launcher type.)
Run them as a two stage process with your "autorun" script calling the second script in a new terminal eg
gnome-terminal -e top --title Testing
Would run the program "top" in a new gnome terminal window with the title "Testing" You can add additional arguments like setting the geometry to determine the size and location of the window checkout the man page for gnome-terminal and the "X" man page for more details
xterm -e shellscript.sh
or (if xterm isn't installed)
gnome-terminal -e shellscript.sh
or (if you're using kubuntu / kde)
konsole -e shellscript.sh

Resources