Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorun a program (1.6.0.4) #2171

Closed
ExDomino opened this issue Dec 10, 2016 · 17 comments
Closed

Autorun a program (1.6.0.4) #2171

ExDomino opened this issue Dec 10, 2016 · 17 comments
Assignees

Comments

@ExDomino
Copy link

Hello, I would like to have a program that is automaticaly executed at the computer startup, but autorun.lua (either placed in "/" or in "home/") doesn't work. My goal is to have a program that runs at the startup and shows every print and allow user interaction, like a normal program executed manually, and if the program only does something like print("test"), the "test" would be printed between the greetings frame and the prompt. Thank you in advance!

@SaphireLattice
Copy link

SaphireLattice commented Dec 10, 2016 via email

@Vexatos
Copy link
Contributor

Vexatos commented Dec 10, 2016

There is also .shrc

@payonel
Copy link
Member

payonel commented Dec 12, 2016

I think I should make a ocdoc page specifically talking about boot scripts and similar needs. But briefly here I'll list your options. I'll save the more detailed howto for each of these to an ocdoc page

  1. /bin/rc can be used to enable boot level scripts. Hopefully in the future of openos this feature is given a pretty nice upgrade; today it is basic.
  2. /autorun.lua (and not /home/autorun.lua) can be used for scripts to execute on drives that are automounted by the filesystem. This doesn't apply to the rootfs. This definitely could use more explanation, please note that this definitely is not what you're looking for.
  3. /etc/profile is "sourced" (as a list of shell commands) each time the shell loads, not just every boot. (e.g. if the user types 'exit' in the shell, the shell would reload but the machine is not rebooting)
  • /home/.shrc is "sourced" via /etc/profile
  • note that /etc/motd is actually run via /etc/profile
  1. You can also create "boot" scripts (these are generally intended for system library initialization). The existing boot scripts are found in /boot, and are numbered to support load order. This system is deprecated (at least in my mind) and I would like to eventually retire this system, fair warning.

@ExDomino
Copy link
Author

You could make that "/autorun.lua" is executed after the prompt? ComputerCraft has an easy way to autorun a program, why not OpenComputers?

@dgelessus
Copy link
Contributor

@ExDomino When OpenOS mounts a drive, it checks if there is an autorun.lua on it, and runs it if there is one. (There is also an option in OpenOS's configuration that needs to be enabled for autorun to work.) Making the shell run autorun.lua would be confusing and problematic - autorun scripts are supposed to run when a drive is attached, not when a shell is started.

If you want to run something every time the shell is started, use /etc/profile, as @payonel described in point 3.

@payonel
Copy link
Member

payonel commented Dec 13, 2016

I recommend editing /home/.shrc rather than /etc/profile purely for organizational purposes.
Again, these files are "sourced" (as shell commands) and not "lua executed". I'll keep further detailed walkthroughs to a ocdoc update.

@Joapfel
Copy link

Joapfel commented Oct 27, 2017

how can I write to.shrc or etc/profile..its all readonly

@skyem123
Copy link
Contributor

@Joapfel, you need to install OpenOS to a hard drive first. Then you should be able to write files...

@payonel
Copy link
Member

payonel commented Nov 9, 2017

a reasonable stub: http://ocdoc.cil.li/tutorial:autorun_options

@ExDomino
Copy link
Author

ExDomino commented May 1, 2018

Sadly there is no way to have an autorun program in OpenComputers, except if you are an expert!
For simple users, after hours of searching, this is simply impossible.

I wanted a computer that is always on, always loaded (by a chunker loader) but it is simply impossible to do so. Only robots can chunk load, they has no screen to debug, and it is just too complicated because the lot of "DRM" in the mod to keep it complicated for no reason.

This mod only exists because the stupid decision of ComputerCraft's authors to make their computers too easy to craft and without any need of power.

@Timsuper
Copy link

Timsuper commented May 1, 2018

No. Just change to root directory / and create a file autorun.lua . Worked for me. My question: does it run in /home/ too?

@ExDomino
Copy link
Author

ExDomino commented May 1, 2018

/autorun.lua is not executed for rootfs!
autorun.lua is only executed when a floppy disk is inserted, and not when the computer starts with this floppy disk already inserted, of course, else it would be really too easy.

And we cannot put a chunkloader into a microcontroller... because of a DRM.
We need a robot just to simply chunk load a simple chunk in the spawn area.

@ExDomino
Copy link
Author

ExDomino commented May 1, 2018

And just a question: someone is supposed to tell me how to run the main script of a robot, that is located on the floppy disk, if the robot cannot autorun the file autorun.lua? Humm? Nobody?

@skyem123
Copy link
Contributor

skyem123 commented May 2, 2018

write a Lua program, call it /home/whatever.lua.
then make a file called /home/.shrc and put the line /home/whatever.lua as the contents. That should autostart the program.

@payonel
Copy link
Member

payonel commented May 2, 2018

autorun on the rootfs is run, just like all the others. what code does your autorun have?

@RubenWindels1
Copy link

I dont know nothing about this mod but I want to install and run this program.
https://pastebin.com/aKjh5SZL
What do I have to do? I searched the internet but couldn't find it.

@skyem123
Copy link
Contributor

skyem123 commented Jun 6, 2018

@SlimeGenX, that is not directly related to the issue. For more direct help, consider asking for help in the IRC channel or Discord Group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants