2009-12-08 08:00:19     Auto start console app

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2009-12-08 08:00:19     Auto start console app

billy walton (UNITED KINGDOM)

Message: 83242   

 

Hi,

 

Sorry for the simple question....but...

 

Is there a way for me to start a console app automatically after boot, so if i was to connect  my serial console i would see it running?

 

I tried in the rc file but it loads and then quits again

 

Many thanks

QuoteReplyEditDelete

 

 

2009-12-08 17:45:02     Re: Auto start console app

Mike Frysinger (UNITED STATES)

Message: 83256   

 

your simple app probably relies on stdin which is disconnected by default in /etc/rc

 

what exactly does your app need to do ?

QuoteReplyEditDelete

 

 

2009-12-09 02:47:26     Re: Auto start console app

billy walton (UNITED KINGDOM)

Message: 83266   

 

yes it relies on stdin and stdout

 

Its a call router, and normally it just sits there spitting out what its doing, any user connection is made using http/boa so the console is all mine - i want to have the app running all the time on the command line so it just sits there and and all i need to do is hook up the serial and i (or someone helping) can read off what its doing.

 

Billy

QuoteReplyEditDelete

 

 

2009-12-09 03:44:48     Re: Auto start console app

Mike Frysinger (UNITED STATES)

Message: 83297   

 

so either reconnect stdin/stdout manually, or in your app, or have it in your inittab (connected to the device you want)

QuoteReplyEditDelete

 

 

2009-12-09 05:31:36     Re: Auto start console app

billy walton (UNITED KINGDOM)

Message: 83299   

 

hmmmm, i think it is always connected. Please excuse me if i missed the answer here

 

I am using the busybox tools, when i boot, the console is always up, and the busy box command line is always waiting for me - i come along, plug in the serial, hit enter and see the prompt.

 

If i put my app in the rc file, uclinux boots, my app loads, then it quits (not by my wishes!) and then i get presented with the busybox command line waiting as normal...

 

What i want to do is let busybox load giving me the prompt, then have that prompt load my app...

 

If you answer will do what im after, could you be so kind to point me to a doc or somethings showing an example of reconnecting the stdout using inittab?

 

Or, does inittab get executed after the command prompt is visible?

 

Many thanks for you help

QuoteReplyEditDelete

 

 

2009-12-09 05:54:36     Re: Auto start console app

Mike Frysinger (UNITED STATES)

Message: 83300   

 

i already said -- /etc/rc is run with stdin disconnected.  you must remap it yourself.

 

you probably dont want to launch both a shell and your application and have them fight over input from the console.  have inittab run a script bound to your console of choice that can handle the logic of picking your app to run or falling back to launching a shell.

QuoteReplyEditDelete

 

 

2009-12-12 08:04:26     Re: Auto start console app

billy walton (UNITED KINGDOM)

Message: 83428   

 

Hi Mike and many thanks for your pointers.

 

So i have took what you wrote and went away to learn about inittab files

 

I am still in a little confusion.  My inittab file is just full of commented lines, no actual commands.  As i have mentioned previously, i am using the built in BusyBox - so i guess somewhere /bin/sh is being executed - but i cannot find it.

 

So i have tried many things in the inittab - all fail with "init: /usr/bin/MyProg exec failed" and "respawning too fast" errors

 

From what i have read, i have based the command on

 

ttyBF0::respawn:/usr/bin/MyProg

 

So i want it to run on ttyBF0, all runlevels, to respawn after quit and the command to run

 

now after what you wrote, i kind of expected to find something along the lines of

 

ttyBF0::respawn:/bin/sh

 

which would have made everything clear, but its not in there, so i guess its because its "built in"?

 

Anyway, im a novice in the inittab area, and most tutorials point to massive files with problems relating to xservers and virtual consoles

 

I think what i need to do is find out where sh is being called from and change things there, or get sh to execute my program on top of it like a user would do by typing in the commands

 

or maybe i have got my inittab syntax completly wrong?

QuoteReplyEditDelete

 

 

2009-12-12 08:31:09     Re: Auto start console app

Mike Frysinger (UNITED STATES)

Message: 83430   

 

if you were using init from busybox, then /etc/rc wouldnt have been run.  you are most likely still using the simple init package.

 

a login shell is launched automatically probably because you enabled it:

  docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:shell

 

figure out which init you're actually using first.  the default inittab that ships with all ADI configs is for simple init.  if you actually switch to busybox, read the busybox documentation/source for the syntax needed to work with it.

QuoteReplyEditDelete

 

 

2009-12-12 11:30:01     Re: Auto start console app

billy walton (UNITED KINGDOM)

Message: 83434   

 

It seems an impossible task

 

I have spent another day on it and still do not know the answer to that question

 

im sure this should be so simple really!

 

So, what i think is the normal way:

 

Core apps-->Init enabled, enable console shell enabled, BusyBox Init disabled

 

I get the errors i described in the previous mail,

 

What i think is the busybox way:

 

Core apps-->Init deselected, busybox-->init selected, then i get lots of applet not found errors, no rc execution, so im sure its the busybox way

 

following the busybox manual, trying examples, casues corruption on the screen (using the askfirst option for example)

 

so now im even more confused, i would consider having a go in the busybox forum but i see your a contrib there too!

 

long live autoexec :-(

 

I reckon for now - unless someone can suggest anything else, im actually going to write a demon app which i can load with rc and it will spawn my console app after a time period for me, seems an awful way around the problem, but i reckon its quicker, and ill have it working in an hour or so!!

QuoteReplyEditDelete

 

 

2009-12-12 11:32:00     Re: Auto start console app

billy walton (UNITED KINGDOM)

Message: 83435   

 

I am using the simple init, the rc is run, so it must be my syntax in the inittab

QuoteReplyEditDelete

 

 

2009-12-12 12:56:30     Re: Auto start console app

billy walton (UNITED KINGDOM)

Message: 83436   

 

hi Mike,

 

Can i start this thread again, i think its going somewhere i dont really want to be at the moment.

 

Can i pose the question like this:

 

"Could someone give me an example, of how i can boot my linux kernel straight into linphonec?, as opposed to having a command prompt and typing it it.  If i then quit linphonec, the command prompt returns"

 

So to break that down, i dont need multiple terminals, or things running in parralell/background - if linphonec is running, then no other command prompt is available, if i want it, i have to quit linphonec.

 

I am using the simple init and inittab, my current makefile contains 1 line:

 

console::respawn:-/bin/sh

 

, and busybox is set to use msh as a default shell.

 

at the moment, i boot up connected to a serial terminal on ttyBF0, i get the command prompt and type linphonec - and thats how it stays all day.  All i want it to do, is type the linphonec bit for me if the power cycles and im not there.

 

Im looking for the simplest way to achieve this (as i cant believe its a complicated request!), if it is a line in the inittab, could you give me an example of what you would put there to do it?

 

Many many thanks, greatly appreciated

QuoteReplyEditDelete

 

 

2009-12-15 13:22:14     Re: Auto start console app

Mike Frysinger (UNITED STATES)

Message: 83532   

 

i told you how to do that already:

  blackfin.uclinux.org/gf/forummessage/83300

Attachments

    Outcomes