Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-31-2007, 07:20 AM
|
#1
|
LQ Newbie
Registered: Mar 2007
Posts: 3
Rep:
|
redirecting ncurses
Hello,
I've got a very special problem.
I want to develop a program, which starts as deamon when linux starts up. Another simple program should be used to get output from the deamon programm and to enter commands. (Like a debug interface)
What I did:
the deamon program can be started with a verbose option to get a screen.(with ncurses). My idea was to redirect the screen with pipes to the second program (debug console)
./deamonProg& < /tmp/pipe1 >/tmp/pipe2
./debugProg /tmp/pipe2 /tmp/pipe1
Is this the right way? or is there any possiblity to change console and keyboard settings directly in ncurses lib?
The problem is, that the debugProg prints trash onto the screen :-(
Can anybody help?
|
|
|
03-31-2007, 07:43 AM
|
#2
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
|
Usually you have a program which does something (the deamon) and a debugger for that.
The debugger is always the part which communicates with the user, displays values and accepts keyboard input. For example, if you use gdb, the program being debugged doesn't even know that it is being debugged, and gdb provides all user interface.
Likewise, I would say that your deamon should have to user interface at all. Your debug program should have an ncurses interface, and you should set up a communication between the two, like TCP sockets.
Another way is this: your deamon has an ncurses interface. It should *only* do this ncurses to the screen, and to ALL OTHER output to stderr. When you start the program, you must redirect stderr to something else, like /dev/pts/3 if you use xterm, or /dev/tty3 if you are on the console.
That way keeps your ncurses interface clean, and all other output of your deamon goes to the other console.
jlinkels
|
|
1 members found this post helpful.
|
03-31-2007, 08:32 AM
|
#3
|
LQ Newbie
Registered: Mar 2007
Posts: 3
Original Poster
Rep:
|
no console during start up and no idea about implementation
ok, to you first suggestion:
Likewise, I would say that your deamon should have to user interface at all. Your debug program should have an ncurses interface, and you should set up a communication between the two, like TCP sockets
--> Can you tell me, how to redirect ncurses input/output to the second programm?
to the second way:
It should *only* do this ncurses to the screen, and to ALL OTHER output to stderr. When you start the program, you must redirect stderr to something else, like /dev/pts/3 if you use xterm, or /dev/tty3 if you are on the console.
--> how can I start a programm in linux within a console automatically during startup?
If the deamon is started in init.d with a script, no console is available for ncurses output!
Otherwise a user has to login.
I want the deamon to be started automatically at startup. the user should have a possibility to intercommunicate with the programm if he logs in.
|
|
|
03-31-2007, 09:18 AM
|
#4
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
|
Quote:
Originally Posted by donshrimps
--> Can you tell me, how to redirect ncurses input/output to the second programm?
|
You should not try to redirect ncurses, but your data. The data is interpreted and displayed by your debugging program. The debugging program should interact with the user, not your process deamon.
Compare it with a web browser. With a web browser you see web pages, information, pictures, but you don't see anything of what the web server does. The web server is the process, the web browser the debugger.
Quote:
Originally Posted by donshrimps
--> how can I start a programm in linux within a console automatically during startup?
|
WHY would you want to start up a program with a user interface without user intervention? Either you don't have a user in front of the screen and what use is a user interface. Or you have a user which is ready for interacting with the debugging program, and for what do you need an automatic startup?
jlinkels
|
|
|
03-31-2007, 09:29 AM
|
#5
|
LQ Newbie
Registered: Mar 2007
Posts: 3
Original Poster
Rep:
|
run program during startup
Quote:
WHY would you want to start up a program with a user interface without user intervention? Either you don't have a user in front of the screen and what use is a user interface. Or you have a user which is ready for interacting with the debugging program, and for what do you need an automatic startup?
|
the program deamon is a gateway for the automation environment (like chemistry industry, power plants. The embedded linux pc starts up and the program should run without user intervention.
User interactions are only for displaying debug infos or simulate sth.
How can I solve that problem?
Can you show me an example (code snippet, tutorial or sth?)
thanx for help
|
|
|
03-31-2007, 09:59 AM
|
#6
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
|
RULE#1 in process controlling environments:
NEVER integrate user interface with your process controller.
Have the embedded controller. Have the user interface. Have them communicating thru TCP.
How would you otherwise want to deal with user interactions? Stop your process while waiting for user input?
I cannot give you any code snippet, because IMHO it is basically a wrong and erroneous approach to have the process controller and user interface running in the same program.
It is the Windows way, they do it with Embedded Windows XP. If Windows hangs, your process hangs. Wow!
jlinkels
|
|
|
All times are GMT -5. The time now is 08:19 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|