LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 09-25-2013, 01:37 AM   #1
WiseDraco
Member
 
Registered: Nov 2006
Location: Europe,Latvia,Riga
Distribution: slackware,slax, exMandriva
Posts: 379

Rep: Reputation: 30
script with output to console 2 ?


Hello!
Have a question - it is possible to make autostart script, with output of that script going to console 2, or 3?

exactly, i want to make a
tail -f /data/recv.log

with output to console 2, i can do that, for sure, manually - log in in console 2, then run that command, but it is possible to automate this?
 
Old 09-25-2013, 04:07 AM   #2
WiseDraco
Member
 
Registered: Nov 2006
Location: Europe,Latvia,Riga
Distribution: slackware,slax, exMandriva
Posts: 379

Original Poster
Rep: Reputation: 30
found it can be done with redirection to console - like as
tail -f /data/recv.log > /dev/tty2

also if i put that line in /etc/rc.d/rc.local , i think, startup procedure stops at this command, because it never ending and run continually.
i think, construction must be like
tail -f /data/recv.log > /dev/tty2 &
to put that command in background?
than all must be work?
 
Old 09-26-2013, 01:13 AM   #3
WiseDraco
Member
 
Registered: Nov 2006
Location: Europe,Latvia,Riga
Distribution: slackware,slax, exMandriva
Posts: 379

Original Poster
Rep: Reputation: 30
there are a problem with output redirecting to console 2 - ">/dev/tty2" - it not work. today i start system, and on console 2 ( ALT +F2) i see only login screen - not any messages....

anyone can help me with this?
 
Old 09-26-2013, 08:05 AM   #4
FeyFre
Member
 
Registered: Jun 2010
Location: Ukraine, Vinnitsa
Distribution: Slackware
Posts: 307

Rep: Reputation: 22
I am unsure in my guess. Well, I don't think /dev/tty2 actually connected to console display in moment of execution of rc.local. I believe it connects to display during execution of command "/sbin/agetty 38400 tty2 linux", which according to inittab will be executed only and only after rc.M terminates itself. So you have a kind of deadlock here.
 
Old 09-26-2013, 08:43 AM   #5
WiseDraco
Member
 
Registered: Nov 2006
Location: Europe,Latvia,Riga
Distribution: slackware,slax, exMandriva
Posts: 379

Original Poster
Rep: Reputation: 30
hm. thank for idea. and where i can, then, write my command to do execute it on startup?
as i understand, rc.m is last script, who autoexecute on startup, and rc.local is last call from rc.m...?
 
Old 09-26-2013, 10:53 AM   #6
FeyFre
Member
 
Registered: Jun 2010
Location: Ukraine, Vinnitsa
Distribution: Slackware
Posts: 307

Rep: Reputation: 22
Yes, rc.M is last before spawning tty's.
Let analyse your task:
You want some startup sciprt to continuously print content of interactive log file (/data/recv.cfg) to some tty(let it be tty2)?
I see next solution:
1. Let prepare command to print log. We shall put into /root/logger
Code:
#!/bin/sh
exec /usr/bin/tail -f /data/recv.cfg
You can make it more complex. Don't forget to set x attribute.
2. We know it is possible after actual connecting tty2 to console(made by agetty).
So our task is to force to call our logger during spawning on tty. Well, after brief reading of "man agetty" and "man inittab"(for testing purposes) solution is oblivious for me.
Go edit /etc/inittab (do backup!!!)
find line "c2:12345:respawn:/sbin/agetty 38400 tty2 linux"
and replace it by line "c2:12345:respawn:/sbin/agetty -n -l /root/logger 38400 tty2 linux"
"-n" means do not prompt username
"-l /root/logger" means run given executable instead standard /sbin/login.
To test it:
1. Completely logoff on tty2(if logged on), switch back to non-tty2.
2. Ask init to re-read /etc/inittab using command: @ telinit q
3. Terminate corresponding tty console by command: @ kill -s $(ps a |grep agetty |grep tty2 |cut -f 1 -d" ") OR use top/htop/... to kill tty2.
init will rerun corresponding process immediately but with new parameters(actually, you can change not only parameters but whole command, it identifies process to rerun by its id, "c2" in out case).
Switch to tty2(alt+f2) now you can see content of your log file in that tty.
As a side effect you cannot login in tty2 any more. Probably there are other side effects, this will be your homework.
 
1 members found this post helpful.
Old 09-27-2013, 02:13 AM   #7
WiseDraco
Member
 
Registered: Nov 2006
Location: Europe,Latvia,Riga
Distribution: slackware,slax, exMandriva
Posts: 379

Original Poster
Rep: Reputation: 30
thank you very much for this workaround, but i be sure, it can be more easy and logic way to get messages output to console 2,3, so.
in fact, many distro in different time do that - as i remember, one time mandrake distro in installation process do various data outputs to various consoles and so on. i think, there must be another variants, without inittab edition, because this is not a nice solution imho.
 
Old 10-02-2013, 12:55 AM   #8
WiseDraco
Member
 
Registered: Nov 2006
Location: Europe,Latvia,Riga
Distribution: slackware,slax, exMandriva
Posts: 379

Original Poster
Rep: Reputation: 30
Running job at statup (boot)

You need to use special string called @reboot. It will run once, at startup after reboot command.

@reboot /path/to/job

http://www.cyberciti.biz/faq/linux-e...system-reboot/

it works. but my output of /var/log/messages to console via tail -f script is some strange formatting - looks like without CR feed. look, what i correct that.
 
  


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
Standard script output to screen & -x option output to file BoBeau236 Programming 6 05-10-2011 07:43 AM
Bash script output to console without login m.dam Linux - General 6 01-07-2011 10:07 AM
How can I output to both console and a file? trewsfan Linux - Newbie 6 08-17-2006 05:25 PM
Console output to X? dcm1878 Linux - Software 4 04-23-2003 08:07 PM
Long console output Loke Linux - Newbie 1 02-26-2003 06:35 AM


All times are GMT -5. The time now is 05:34 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration