Click to See Complete Forum and Search --> : Can I remotely control a TTY?


tangoj
06-05-2003, 08:25 AM
(Please excuse me if I use the wrong terminology...I'm definitely a newb!!!)

I run an application in tty5 of my RH7.2 machine and sometimes the application locks up requiring me to reboot. Also, the application runs my email so I have no communications while it is down.

The problem is that I have to manually restart the application (have to log in and start the script) on tty5.

My question is, can I access tty5 remotely and start the application after I've rebooted the server?

Or, is there a way to have the machine automatticaly log in with a specific user ID & PW on tty5 and start the application script every time it boots up?

Help! I'm drowning in my own newbness!

tangoj

serz
06-05-2003, 12:21 PM
Why don't you just start that script when your system boots?

Hayl
06-05-2003, 12:31 PM
Originally posted by serz
Why don't you just start that script when your system boots?

he does but it (the script) sometimes hangs and he needs a way to restart it in a specific TTY.

Syntaxis
06-05-2003, 12:44 PM
Heya,

It sounds like you're talking about a daemon (server) process, presumably a MTA (mail transport agent, i.e. mail server) of some kind, dying on you unexpectedly.

The simplest thing to do would be to use something like DJB's daemontools (http://cr.yp.to/daemontools.html) which has a supervisor process that will restart monitored processes when they die. There are a couple of other methods that essentially accomplish the same thing, for example Runit (http://smarden.org/runit/). This sounds like what you're after?

I'm not entirely sure why it has to be run on tty5 specifically, either. You can use something like Telnet (or preferably OpenSSH, which encrypts the communications) to log in remotely to the server and then run any commands you wish. It's scriptable, too, though you'd still have to invoke it manually because how would it know when the application on the server has died? The daemontools/runit approach (outlined above) sounds better to me.

HTH :)

tangoj
06-05-2003, 01:03 PM
Originally posted by serz
Why don't you just start that script when your system boots?

If you give me a hint as to how to do this, I'd certainly try it.

I have tried mod'ing the inittab file and putting something like:
5:3 respawn /scriptspath/runapp

but all I end up with is a dead, blank screen where the script should have run. (And no, it's no the script, it runs just fine).

I did see a post earlier in my searching today that said something like:
5:3 respawn su username /scriptspath/runapp tty5

Will that work?

If you have a better way to start an interactive session (not a daemon!) and have it run a script that starts an app, with a specific user name, I would be happier than a pig in slop!

tangoj

tangoj
06-05-2003, 01:05 PM
Originally posted by Hayl
he does but it (the script) sometimes hangs and he needs a way to restart it in a specific TTY.

Actually, I'm manually logging in and runnign the script. If I could load/run it a bootup, that would solve my problem as I could just reboot the machine remotely if got hung up. Unfortuneatly, I haven't found a way to run a script in a tty after bootup.

Do you know how to do that? Thanks!

tangoj

tangoj
06-05-2003, 01:09 PM
Originally posted by Syntaxis
There are a couple of other methods that essentially accomplish the same thing, for example Runit (http://smarden.org/runit/). This sounds like what you're after?

I'm not entirely sure why it has to be run on tty5 specifically, either.

I have to run it in a tty (and no, it doesn't have to be tty5 specifiacly...I was just using it for examples) because it's interactive. If it was a daemon, the method you suggested would work great....too bad I can't do that.:mad:

tangoj

tangoj
06-05-2003, 01:16 PM
Thanks for the input...I really appreciate it! Maybe it would help if I laid out more specifically what my goal is:

Upon bootup, an interactive application is automattically started in a tty, running under a specific user id.

What I think I need is:
1. Auto log in as user - Can be done with su- , right?
2. Run script to start app - That's just './scriptname', right?
3. Have all this happen at bootup - Mod the inittab file to run step 1 & 2 ??? This is the part I'm stuck on.

The whole goal is to have the machine auto load and run my app when it boots?

Can anyone offer any more ideas for me to try??

Thanks again for the help so far.

tangoj

Syntaxis
06-05-2003, 01:59 PM
Mingetty is one way of achieving auto-login as a given user, though I'm sure that as per the UNIX philosophy there are a thousand-and-one other, equally good ways. See http://www.linuxgazette.com/issue27/kodis.html for a nice tutorial - it's a little old, but I'm sure nothing major's changed since then. It also gives an example of how to automatically execute code upon login.

Unfortunately, I don't know of a way to automatically restart the interactive process when it dies, which is I think the other thing you're after.

EDIT: Whoops, I forgot about inittab's "respawn" option, silly me.

tangoj
06-05-2003, 03:38 PM
Originally posted by Syntaxis
Mingetty is one way of achieving auto-login as a given user, though I'm sure that as per the UNIX philosophy there are a thousand-and-one other, equally good ways. See http://www.linuxgazette.com/issue27/kodis.html for a nice tutorial - it's a little old, but I'm sure nothing major's changed since then. It also gives an example of how to automatically execute code upon login.

Unfortunately, I don't know of a way to automatically restart the interactive process when it dies, which is I think the other thing you're after.

EDIT: Whoops, I forgot about inittab's "respawn" option, silly me.

OUTSTANDING!!! Thanks for the tip! I tried agetty, but not mingetty. I'll give it a shot tonight.

One last follow up, if I do get it to auto log on, is there a file/script that runs whenever that user logs in? Is it .bash.rc or something? And can I edit that file to start up my application?

I really appreciate the help. I've been struggling with this for a few months. Thanks!

tangoj

Syntaxis
06-05-2003, 04:42 PM
Np, that's what we're here for. :)

Yep, you're thinking of ~/.bash_profile, which is sourced by bash whenever you log in interactively; whatever commands you add to the file, bash will run. There's an example in that LinuxGazette article.

EDIT: Found another LinuxGazette article, "Make Your Virtual Console Log In Automatically" (http://www.linuxgazette.com/issue69/henderson.html) which lays out yet another way of accomplishing this, using something called Qlogin instead of mingetty. Just for variety's sake. :D