WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Autostart non X application  (Read 2980 times)

Offline awatar100

  • Newbie
  • *
  • Posts: 13
Autostart non X application
« on: September 01, 2013, 06:50:30 AM »
Hello all
I have question -
How to start non x application after TCB boot?
I write small application that read lpt port status and send it to file at /tmp/temp
When i start it manualy "sudo /mnt/sda1/tce/my_prog" app is working but when i add the same command to /opt/bootlocal.sh it dont start (i  try to use "exec /mnt/sda/tce/my_prog") but no beter result.
TC is running from /mnt/sda1 device so im sure when bootlocal.sh call to sda1 its mounted. Im not sure but it can be something coonected to reading( low level functions i c that read lpt port)

Basically my question is :
where i have to add sudo /mnt/sda1/tce/my_prog
that will start after auto login of tc user (after welcome message is displayed)
Or add this that way that will work.

PS Tinycore is CoolAndAwesom stuff

 8) 8) 8) 8) 8)

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Autostart non X application
« Reply #1 on: September 01, 2013, 10:18:14 AM »
When running from bootlocal.sh do NOT use sudo.
The use of exec will replace the currently running shell with the new program.
That is not something you want to happen in bootlocal.sh, as anything after that line will never run.

Offline awatar100

  • Newbie
  • *
  • Posts: 13
Re: Autostart non X application
« Reply #2 on: September 01, 2013, 10:55:10 AM »
This will be non human pc so if this program start i will be happy and no shell will be needed. .. so im asking how to do it , not why i cant ∩_∩ exec , sudo dont work ...

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Autostart non X application
« Reply #3 on: September 01, 2013, 11:15:48 AM »
You do it by NOT using sudo or exec in bootlocal.sh

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11502
Re: Autostart non X application
« Reply #4 on: September 01, 2013, 12:06:33 PM »
Hi awatar100
Does it work if you add this to  bootlocal.sh:
Code: [Select]
/mnt/sda1/tce/my_prog &

Offline awatar100

  • Newbie
  • *
  • Posts: 13
Re: Autostart non X application
« Reply #5 on: September 01, 2013, 12:56:09 PM »
No it dont (i test it now) and it cant work. to program low level io in linux you have to have root rights my program  read and write to io of lpt so it has to start with root ... best way is to start it after welcome msg.  That user see after start

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Autostart non X application
« Reply #6 on: September 01, 2013, 01:01:11 PM »
bootlocal.sh runs as root.  You must be sure your program is not expecting to read from stdin.

Offline awatar100

  • Newbie
  • *
  • Posts: 13
Re: Autostart non X application
« Reply #7 on: September 01, 2013, 03:29:02 PM »
Hmm so im stuck , my program printf some msg on screen when i start it by manual but it did not send msg when it is added to bootlocal also i dont see file that it create in tmp so it not start
as for stdin i use some part from it (i think )read from /dev/ttys0 (no human interaction is need no kbd input) i cant see it in top and it cannot be started with & so it not start when it is added to bootlocal, so small hack - where is welcome msg store on tinycore

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11502
Re: Autostart non X application
« Reply #8 on: September 01, 2013, 03:43:05 PM »
Hi awatar100
Try adding some diagnostic messages to your program to see where the problem is. You can use  fprintf  to print them
to a file. Make sure to close and reopen the file between messages so the buffers get flushed.

Offline awatar100

  • Newbie
  • *
  • Posts: 13
Re: Autostart non X application
« Reply #9 on: September 05, 2013, 01:12:43 PM »
Hi all i have found what is problem in my case ....:
as i write before my application cannot be started in background, so adding myapp to bootlocal.sh is really bad advice..why ? because
First tinycore calls Bootsync.sh -> this file call bootlocal.sh but already in backgound (bootlocal.sh &) - and this was problem in my case
i just del "&" in bootsync.sh and all  now is OK

 ;) ;)
case solved