Link to home
Start Free TrialLog in
Avatar of J C
J CFlag for United States of America

asked on

Start program at startup in specific tty?

Hello all,

I would like to know how I can start a program at (or after) start up in a specific console (anything above 1). I am running FC2 and just want to make sure this program starts back up after reboot.

Thanks,
GR
SOLUTION
Avatar of Caseybea
Caseybea

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of J C

ASKER

Ok that would definately work, but I need it to run in a console (tty). Would that mean I would have to automatically login in to a tty then execute the program in that tty? It is a small server program that has a console to query status and issue other commands. Also on line 4 "#! /bin/sh" does that need to be in there? Wouldn't the script error out on this?

Thanx
GR
Avatar of stokesj56
stokesj56

About the #!/bin/sh (notice no space), this is not strictly needed but should be included. This tells the system which command interpreter to use to execute the script. In this case use /bin/sh (bourne shell). If you did not include this the system would use it's default shell (most Linux distributions use BASH, some systems use Korn shell, etc.) Some commands act differently in different shells.

If you want a commant to run whenever you login on certain terminals then put this in your .profile (or other startup script depending on your defaul shell):

TTY=`tty`
TT1=`basename $TTY`
TT2=`echo $TT1 | sed 's/[^0-9]//g'`
if [ "$TT2" -gt 1 ]
then
    # Insert your command here.
fi

This will run everytime you login. If you only want it to run the first time you login you will need to add some further checks.
Avatar of J C

ASKER

I'm sorry if I was not clear before, but what I need is to start a program after a reboot in a console (tty5). This would need to be done without any user intervention. I can run the program after start up, but would like to run it in a console. I appreciate all your help.

Thanks,
GR
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of J C

ASKER

Thanks for the help guys!

GR