Equivalent for Linux's "screen" - linux

Is there anything similiar to Linux's "screen"? What I want to do is launch console application created in Java. Then let's say I want to execute command to the running application. For example I want to tell it to exit so I'll tell it command 'exit'. On Linux I can open the application "in screen" and later if I want to tell it any command I can attach the "screen", tell it the command and detach. I don't need screen but I need something that can do this. It would also be cool if I could do it without installing any additional software.

You can install cygwin and within cygwin install screen.

Related

How do I create a shortcut for a command line command in Raspbian Stretch?

I am attempting to install RetroPie as an app on Raspbian Stretch and I am done except for creating a desktop shortcut for it. The problem is that the only way to open RetroPie seems to be running a command in the command line. I can’t do it in terminal because it gives me an error saying that it can’t initialize the window. Is there a way to run a command line command as a shortcut or am I going to have to find another way of doing this?
P.S. Here is the tutorial that I followed to install RetroPie:
https://www.makeuseof.com/tag/install-retropie-app-raspberry-pi/
Probably your shell (on the raspberry) is GNU bash. So read the manual of GNU bash.
You probably want (once) to edit some Bash startup file (such as ~/.bashrc) to define functions and aliases there, and you could add executable shell scripts somewhere in your $PATH. I recommend having a $HOME/bin/ directory containing your scripts and executables, and have $HOME/bin/ early in your $PATH.
I can’t do it in terminal because it gives me an error saying that it can’t initialize the window.
Perhaps you need some display server (such as Xorg or Wayland) running (with a desktop environment or a window manager). You could run Xorg on your PC (on which you could install Linux) and connect to the raspberry using ssh -X then remote applications running on your Raspberry are displayed on your PC. IF your Raspberry is directly connected to a screen (via HDMI) you might run some Xorg server on it.
Is there a way to run a command line command as a shortcut
Yes, by making a shell alias or shell function or shell script. You need to understand how they work and change or create some appropriate file using some source code editor (I recommend GNU emacs, but the choice is yours and you might use any other editor such as vim, gedit, etc...): functions and aliases could be defined in your ~/.bashrc; shell scripts would usually have their own file with a shebang under your $HOME/bin/...

Using tmux through Cygwin: "open terminal failed: not a terminal"

I'm trying to use tmux on a Windows Computer. I successfully installed tmux using
apt-cyg install tmux
I can confirm successful installation because I get the following:
$ tmux -V
tmux 2.3
However, when I try to type "tmux" in the console, I get the following error:
open terminal failed: not a terminal
Any thoughts?
It sounds like the terminal you're using doesn't support full tty emulation. Clients like mintty (comes with Cygwin---or should, anyway), putty, rxvt for Windows, &c. will handle that. CMD, ConEmu, and Cmder won't.
There's not much to be done here without a huge ordeal (See second comment: https://news.ycombinator.com/item?id=8577817). Unsatisfying though it may be, the best answer is to make sure you're running mintty. CYGWIN.bat should run it out of the box, so if that's not working, try running it directly from Explorer instead of from CMD. Otherwise, you might need to poke around in the batch file and make sure C:\Cygwin64\bin\mintty (or what have you) is being called.

Using script to automatically start program when the system boot up (linux, shell)

Here is the situation, I'm planning to use a simple script to start a program call "STAF", when the Suse system is fully booted. I have achieved this by putting it in the "/etc/init.d/", but this script is basically executed at the background, which means that I cannot see its progress.
When the "STAF" is started this way it works but it doesn't show any working progress when its running service (for example ping, or system backup), instead if I start the "STAF" manually by running the same script whit a terminal, the working progress of "STAF" can be seen on the terminal. Its sort of like the program needs to be started with a interactive terminal, but how can I make this starting process automatic and it should imitate human opening a terminal and run the script?
Sorry if I explained it poorly because its a confusing situation. Thanks.
First, go to the KDE Startup and Shutdown options under System Settings. Then add this command as a new startup script:
konsole -e bash nameofyourscript.sh
I believe the screen utility can do what you describe. Instead of running STAF on startup, you would run screen STAF. To open that terminal, you would run screen -ls to get the screen ID, and screen -r ... to open it.
(Disclaimer: I have not tried this.)

run c program at startup

I am a beginner to linux programming. What I want to do is, run a C "Hello World" program at startup. Once the user logs in, run that C program. How can I achieve this?
I am running Ubuntu 8.04.
you can create a script inside /etc/init.d/myScriptName which inside this script you start you program
remember to give chmod +x to your script to give execution permissions
I've done that on my machine.
First, in your menu bar, click System, then Preferences, then click Sessions.
A list of startup programs will be shown. click + button and add your script.
This might differ on linux distro. But at least you got the idea.
I solved it by writing a bash script

Displaying instructions to user after .deb installer completes

Is there a commonly used approach for displaying 'how to get started' instructions to a user after a .deb installer has finished installing a package?
I need an approach that works for users working via a terminal as well as from a desktop environment.
Server admins will probably know to check for a README file but many others won't.
I'd suggest running the "tty" command from your postinstall script. That will tell you if you have a tty and are running as a terminal program. Once you know that you could either "more" a readme file if you're running in terminal mode or you could call "gnome-text-editor" if not. You might also want to put in some detection to check "/etc/lsb-release" so that you know what distribution your .deb is being installed on and which editors will be suitable.
I use the tty command like Benj suggested, but I use the dialog command to display post install chatter if its available on the system.
Try this command:
dialog --backtitle "All done" --title "Installation complete" --textbox /etc/passwd 0 0
... but replace /etc/passwd with your README of choice. Its a much nicer way to scroll through information.
After a bit of experimentation it looks like I can detect how the .deb package has been installed by checking the value of the DEBIAN_FRONTEND variable in the postint.sh script. When run from the desktop it contains the value 'gnome', but when run via dpkg from the command-line it isn't set, so something like this might work:
HELP_URL="http://mysite.com/help.html"
if [ "$DEBIAN_FRONTEND" = "gnome" ]; then
nohup gnome-www-browser $HELP_URL &
else
echo For help visit $HELP_URL
fi

Resources