LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 09-08-2010, 11:32 AM   #1
jtag
Member
 
Registered: Aug 2008
Posts: 33

Rep: Reputation: 0
Question How can I start a program from tty1 console to be executed in tty2 console?


How can I start a program from tty1 console text mode to be executed in tty2 console text mode?

Actualy I would like to start a program (chat client cli program) in tty8 automaticaly when linux PC boots.

Thank you

Last edited by jtag; 09-08-2010 at 11:47 AM.
 
Old 09-08-2010, 11:56 AM   #2
rcbrgs
Member
 
Registered: Aug 2010
Posts: 30

Rep: Reputation: 14
Using GNU's screen is an option?

If so, you can start screen automatically on startup, using a specific screenrc configuration file, that automatically runs your chat program, and then detaches. That means that your screen will be running your chat on background, and you can pop it up on any tty you'd like.

The relevant .screenrc lines should be:

screen
stuff "my_chat_program^M"
detach

(The ^M is to feed a newline char to the command. If you want/need more commands, say cmd1 and cmd2, do:
stuff "cmd1;cmd2^M").

Once started, a screen session with this rc will auto-detach. To resume it, you have to call screen with the -r option. (If you get stuck with multiple screens, use -xRR which will most often than not do the trick - check the manual).
 
Old 09-08-2010, 01:02 PM   #3
jtag
Member
 
Registered: Aug 2008
Posts: 33

Original Poster
Rep: Reputation: 0
I can start the program in background using /etc/inittab but I dont know how to pop it up on a specific tty.
My linux pc does not have the graphical interface installed, only command line.
 
Old 09-08-2010, 01:14 PM   #4
rcbrgs
Member
 
Registered: Aug 2010
Posts: 30

Rep: Reputation: 14
The GNU screen program works both in graphical and console terminals, so it should work in your setup.

Also, I do not know how to foreground a program ran in background through inittab. AFAIK, the background/foreground facility is built into bash (maybe in other shells also?), and each tty has its separate bash instance.

That is why you can't background something in tty1 with ctrl+z and foreground it on tty2 with "fg %program", though that would be really useful for you.

Screen does this and much more, I really recommend you give it a try, it will solve your problem and supply you with an invaluable GNU/Linux tool.
 
1 members found this post helpful.
Old 09-08-2010, 01:21 PM   #5
jtag
Member
 
Registered: Aug 2008
Posts: 33

Original Poster
Rep: Reputation: 0
I found this is working also:

vim /etc/inittab

5:2345:respawn:/sbin/agetty -n -l /opt/myprogram 38400 tty5 linux
 
Old 09-08-2010, 01:30 PM   #6
rcbrgs
Member
 
Registered: Aug 2010
Posts: 30

Rep: Reputation: 14
Clever! You added the myprogram invocation to the tty spawner. When you quit myprogram, do you get a shell or does myprogram respawns? (IOW does tty5 becomes "locked" in a chat screen?)

Anyway, congrats!
 
Old 09-10-2010, 07:13 PM   #7
jtag
Member
 
Registered: Aug 2008
Posts: 33

Original Poster
Rep: Reputation: 0
YES, this is exactly what I need. I have the first console with the main program (ALT+F1) and (ALT+F8) is using all the time the chat program for SUPPORT on the main program. The chat clients will connect on a central server (Openfire).
Clever?

Last edited by jtag; 09-10-2010 at 07:14 PM.
 
  


Reply



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
finger shows logged in to console (tty1), even after logging out diskoe Slackware 14 05-15-2007 03:35 PM
How do i switch from tty1 to tty2? alex1986 Linux - Newbie 4 07-27-2006 06:01 AM
Disabling screensaver on tty1 (virtual console) ElectroLinux Linux - General 11 05-02-2006 09:22 PM
Can only start program from console, link doesn't work. longblock454 Linux - Newbie 12 02-02-2005 07:18 PM
Can't start program using X in root console! nyk Linux - Software 7 02-10-2004 06:46 PM

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

All times are GMT -5. The time now is 08:39 AM.

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