Newsgroups: comp.os.linux.embedded Subject: Re: start/stop the application on embedded system from another computer References: <[email protected]> Samwrites: > Hi friends, > > I wrote a program on an embedded system and have trouble controlling > it from my Linux host connected to this embedded system through > network. > > 1. Close the terminal, not the application > > I can start a terminal on my Linux host, telnet the embedded system > and start the application. However, as soon as I close the terminal on > the Linux host, the application will terminate too. How can I keep the > application running after I close the terminal? I definitely want it > to be running independent of my Linux host actions. nohup is a Unix command that is used to run another command while suppressing the action of the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. It is most often used to run commands in background as daemons. Another possibility is to use screen. Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill the current window, view a list of the active windows, turn output logging on and off, copy text between windows, view the scrollback history, switch between windows, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the users terminal. > 2. Start the application as embedded system turns on > > Currently I can start the application from the Linux host. However, I > won't have a Linux host in the field and I want the application to be > automatically turned on as the embedded system powers up. What should > I do to make the embedded system load and start the application for > me? Normal Linux distributions have init / rc mechanisms to start the system services. Add a start script for your application to the /etc/inid.d/ directory and change system starting settings so that it will start when system boots up at the suitable time (after the services that it needs have started). Check the documentation of the Linux distribution you use. Start scripts are one thign where there is quite variation between different Linux distributions. > 3. Monitor the application > > When I start the application on the embedded system from a terminal on > my Linux host, the terminal displays the standard outputs (produced by > C++) from the application. That's how I monitor the application now. > However, if the application is already running, how can I catch and > display the standard outputs on the Linux host? Can I start a terminal > and then somehow catch the outputs? You can do this for example with screen tool. Start screen. Start your application it it. Detach screeen. Log in some later time and resume later to that screen session. You will see what was pritned to screen when you wer away (there is a scrollback history etc.). That's one way to do that. Maybe not always the best, but has worked well many times with Unix/Linux system (I have used screen normally on non-embedded server systems). > 4. Keyboard control the application > > How can I strike certain keys from my Linux host and control (start/ > stop/resume) the application on the embedded system? Should I first > start a terminal and connect to the application? What kind of > functions should I write in the application? One way to do that is to write the application as normal console application that takes the input from standard input. Do read characters from stdin (if there is any). Then do the screen trick to connect and disconnect the terminal from the application. > I just started building applications on Linux and embedded systems a > month ago and have these rudimentary questions. I greatly appreciate > any help you can give to me, I have done that quite much longer time... -- Tomi Engdahl (http://www.iki.fi/then/) Take a look at my electronics web links and documents at http://www.epanorama.net/