I think you're confusing a
terminal emulator (konsole,Xterm,rxvt,...) with a
shell (sh,bash,csh,...)
A terminal emulator is just a frontend to allow you to use a CLI program (typically, a shell) inside a GUI desktop environment. It runs the CLI program for you, it sends whatever you type to the program and it displays its output in a window.
A shell is a program that actually interprets and executes the commands.
Quote:
Originally Posted by Johng
When I run the script below as root, a terminal opens, and after a delay prints an output (but does not advance to the 'ready for next command state':
Code:
#!/bin/sh
set -x #echo on
konsole --noclose -e /usr/sbin/fstrim -v /
/: 165.5 MiB (173498368 bytes) trimmed
|
The
--noclose argument tells
konsole to remain open after the program being run within it (usually, the
shell) exits. That is good if you want to examine the output before closing it, but nothing else. With the shell having exited, the
konsole instance basically becomes a dead, non-interactive window. You can still type into it, but there is no program to recieve the data.
The
-e fstrim ... switch tells konsole to run
fstrim (with the arguments specified) as the program (that is,
instead of your default shell, it runs
fstrim). That is possible and works, but you cannot expect
fstrim to interactively interpret shell commands.
So, what you seem to want is:
1/ the program run within
konsole should be a shell.
2/ no --noclose option. You don't want
konsole to remain open after the shell exits. You want the
shell to not exit after it is finished.
Therefore, what you really should be studying is the man page of the shell, rather than the man page of konsole.
Using all the information above, something like this could work for you:
Code:
konsole -e sh -c "echo Trim SSD; /usr/sbin/fstrim -v /; sh"
However, I agree with
grail. What you're trying to do seems a little weird. I wonder what you're actually trying to achieve in the first place. Perhaps you want to run this from
cron? Or you intend to assign a keyboard shortcut for it?