LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-17-2009, 11:36 AM   #1
billysdomain
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Rep: Reputation: 0
stdin redirect


Hi All,

Could someone be so kind as to give me an example of how i would write an inittab entry which would run a program on boot with sdtin and stdout being redirected to an already established serial terminal?

somthing like

myprog:2345:respawn:/usr/bin/myprog > ttyS0 < ttyS0

That would be great, im a windows man missing an autoexec file at the moment :-(
 
Old 12-17-2009, 01:00 PM   #2
thndrchld
Member
 
Registered: Dec 2009
Posts: 33

Rep: Reputation: 1
Quote:
Originally Posted by billysdomain View Post
Hi All,

Could someone be so kind as to give me an example of how i would write an inittab entry which would run a program on boot with sdtin and stdout being redirected to an already established serial terminal?

somthing like

myprog:2345:respawn:/usr/bin/myprog > ttyS0 < ttyS0

That would be great, im a windows man missing an autoexec file at the moment :-(
Does it need to run from inittab?

You might do better to create a script to start it in /etc/init.d and creating a symling in /etc/rc#.d where # is the runlevel you want the program to run in. If you want it in multiple runlevels, put it in each that it would apply to, eg: rc2.d, rc3.d, rc4.d, etc. The symlink should follow the naming convention S(number)(scriptname), like S95myprog

The scripts are ran in numerical order, so put it where you want it in the startup sequence.

As for terminal redirection, you can combine stderr and stdout using 2>&1. I'm not very great at terminal redirection to serial, but you can try playing with named pipes. Try 'man mkfifo' and see if that info helps.
 
Old 12-17-2009, 01:21 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
What thndrchld said about using a boot script (unless you especially want the init respawn feature) except the specifics of the boot process vary between distros so the file-symlink-directory structure described may not exist on your system. If not, which distro are you using?
 
Old 12-17-2009, 02:11 PM   #4
thndrchld
Member
 
Registered: Dec 2009
Posts: 33

Rep: Reputation: 1
Well, yeah. I'm so used to debian-based distros I forgot other systems do it differently.
Whoopsie.
 
Old 12-17-2009, 02:59 PM   #5
billysdomain
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
What thndrchld said about using a boot script (unless you especially want the init respawn feature) except the specifics of the boot process vary between distros so the file-symlink-directory structure described may not exist on your system. If not, which distro are you using?
very well pointed out - and your correct

Its uClinux - and i dont have any runlevels as such

Im after the syntax to redirect to the serial terminal more then anything
 
Old 12-17-2009, 03:03 PM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by thndrchld View Post
Well, yeah. I'm so used to debian-based distros I forgot other systems do it differently.
Whoopsie.
Easy for me to spot the whoopsie -- I've done the same whoopsie at least once
 
  


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
bash stdin redirect Yustu Programming 3 03-13-2009 08:01 PM
How to redirect the stdin and stdout of child process which exec interactive prog? john.daker Programming 1 11-04-2008 09:27 AM
Statistics from stdin? edeca Linux - Software 0 05-23-2005 11:03 AM
stdin and NUL. How ? Mike Davies Linux - Software 5 10-28-2004 08:06 AM
redirect stdin/stdout of running process xtravar Linux - Software 3 03-06-2004 08:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:10 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