LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 03-31-2007, 07:20 AM   #1
donshrimps
LQ Newbie
 
Registered: Mar 2007
Posts: 3

Rep: Reputation: 0
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?
 
Old 03-31-2007, 07:43 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
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.
Old 03-31-2007, 08:32 AM   #3
donshrimps
LQ Newbie
 
Registered: Mar 2007
Posts: 3

Original Poster
Rep: Reputation: 0
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.
 
Old 03-31-2007, 09:18 AM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
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
 
Old 03-31-2007, 09:29 AM   #5
donshrimps
LQ Newbie
 
Registered: Mar 2007
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 03-31-2007, 09:59 AM   #6
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to print text in color by ncurses without opening a ncurses window Greatrebel Programming 0 12-20-2006 09:15 AM
Redirecting Server Cottsay Linux - Software 3 11-13-2006 08:43 AM
Google Redirecting? the_imax General 1 12-31-2004 11:01 AM
Redirecting Half_Elf Linux - Networking 2 09-04-2002 10:51 PM
ncurses-5.2-28 conflicts with file from package ncurses-5.2-12 tubby Linux - Software 4 06-16-2002 12:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration