WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Run a script as soon as TC boots  (Read 3996 times)

Offline christully

  • Newbie
  • *
  • Posts: 28
Run a script as soon as TC boots
« on: January 22, 2019, 10:58:25 AM »
So, Google lead me to this:

http://forum.tinycorelinux.net/index.php/topic,6783.msg35691.html#msg35691

from which I gather that many years ago, the accepted method to do what I want to do is to put a simple script in ~/.X.d

I have done that:

/home/tc/.X.d/menu
Code: [Select]
#! /bin/bash

source /opt/bin/menu.sh

/opt/bin/menu.sh does exist and is part of core.gz (added by me), and runs if I just type menu.sh at the command line. And, i have just tested that from the command line I can type ~/.X.d/menu and get the result I expect.

So, my analysis is that my script in ~/.X.d is being ignored?

Or, Am I going about this all wrong?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Run a script as soon as TC boots
« Reply #1 on: January 22, 2019, 11:12:11 AM »
Hi christully
Try changing the script in ~/.X.d to just:
Code: [Select]
/opt/bin/menu.sh &

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Run a script as soon as TC boots
« Reply #2 on: January 22, 2019, 11:33:21 AM »
Hi christully
Or does your program need a terminal to execute? Then maybe something like this:
Code: [Select]
exec cliorx /opt/bin/menu.sh &

Offline christully

  • Newbie
  • *
  • Posts: 28
Re: Run a script as soon as TC boots
« Reply #3 on: January 22, 2019, 01:17:11 PM »
Hi Rich,

Thanks for the suggestions!

Option 1 - no dice...  Trying Option 2... also no dice...

Both options just dump me at the command line. I've tried several variations on the options you posted, including making sure that the file is owned by tc.

If I manually execute the ~/.X.d/menu file in either configuration that you posted, my scripts run. But none of the variations I have tried get it to run on boot.

:puzzled:

Offline christully

  • Newbie
  • *
  • Posts: 28
Re: Run a script as soon as TC boots
« Reply #4 on: January 22, 2019, 01:27:53 PM »
And, I think I may know why the ~/.X.d/ option is not working for me. From the wiki:

http://wiki.tinycorelinux.net/wiki:the_boot_process
Quote
#.xsession
…the file ”.xsession” in /home/tc, is called. It starts X, the X desktop, and also autostarts any custom scripts in /home/tc/.X.d.

I don't even have X installed.  I am working with a "Core" install of TC.  No GUI, just CLI.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Run a script as soon as TC boots
« Reply #5 on: January 22, 2019, 01:31:32 PM »
Hi christully
Then place the command at the end of your  /opt/bootlocal.sh  file.

Offline christully

  • Newbie
  • *
  • Posts: 28
Re: Run a script as soon as TC boots
« Reply #6 on: January 22, 2019, 03:37:14 PM »
Rich -  :)

That worked... But not quite.

My script runs but does not pause for user input like it is supposed to.  Instead it just quits and drops me back at the command prompt.

Chris

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Run a script as soon as TC boots
« Reply #7 on: January 22, 2019, 03:48:21 PM »
Hi christully
Then try it like this at the end of your  bootlocal.sh:
Code: [Select]
/opt/bin/menu.sh

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Run a script as soon as TC boots
« Reply #8 on: January 22, 2019, 07:52:38 PM »
Hi Rich.  Is it possible the interactive script is expecting BASH and bash is not installed?

Just a thought..


Sent from my iPhone using Tapatalk

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Run a script as soon as TC boots
« Reply #9 on: January 22, 2019, 08:04:29 PM »
Hi coreplayer2
I don't think so. He said:
... If I manually execute the ~/.X.d/menu file in either configuration that you posted, my scripts run. ...
I think what may be happening is his menu script was being backgrounded and control was returned to bootlocal.sh instead
of waiting for input. I think that explains this result:
... My script runs but does not pause for user input like it is supposed to.  Instead it just quits and drops me back at the command prompt. ...

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: Run a script as soon as TC boots
« Reply #10 on: January 23, 2019, 03:37:48 AM »
For command-line scripts that expect user input, try ~/.profile. It gets executed on the tc user login.
The only barriers that can stop you are the ones you create yourself.

Offline christully

  • Newbie
  • *
  • Posts: 28
Re: Run a script as soon as TC boots
« Reply #11 on: January 23, 2019, 12:32:59 PM »
Rich-

Thanks for the suggestions of why things are working the way they are - that makes sense.

curaga-

I will try that now!

Offline christully

  • Newbie
  • *
  • Posts: 28
Re: Run a script as soon as TC boots
« Reply #12 on: January 23, 2019, 12:58:50 PM »
And an update- curaga's suggestion worked like a charm!

I just added:

Code: [Select]
/opt/bin/menu.sh[\code]

to the end of my ~/.profile and my script runs like I expect it to run.

THANK YOU