Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a script (let's say Hello World), that I want to include to my embedded Linux. I'm using Buildroot and want to start the script in Busybox. But because I'm cross-compiling for the target I'm not sure where to put that script, that in the end it's gonna be compiled and can be executed in Busybox.

share|improve this question

3 Answers 3

a shell-script does not need to be compiled, in order to be run: the nature of scripts is to be run directly by an interpreter (your shell-implementation).

hence, you only need to put the script into a place where it will be found by your shell. for administrator-installed scripts, the preferred place is /usr/local/bin (or /usr/local/sbin if the script is to be run in "administrator mode"). make sure that the script has proper permissions.

# cp /path/to/script/hello_world.sh /usr/local/bin
# chown root.root /usr/local/bin/hello_world.sh
# chmod a+x /usr/local/bin/hello_world.sh
# hello_world.sh
Hi there!
#
share|improve this answer
    
yes i know. But where to put that script, that next time when i hit "make" I'm sure it's included in the generated image for the target? –  user3085931 Jan 22 at 9:03
    
this depends on your Makefile. –  umläute Jan 22 at 9:09

I've found there are several ways to do so. I created an fs-overlay, hit make, and it was part of the Image.

Thanks for the advice.

share|improve this answer

If you want the script to run at start up and you are using the busybox init process in your system then place a script in the /etc/init.d directory.

You need to make sure that your script file name is of the form

SXFilename

where X is some integer that specifies the order that it is executed in - the lower the X value the earlier that the script will run. Depending on how you configured buildroot you should see some scripts similarly named already in your /etc/init.d directory. I am assuming above that you have not edited your inittab file to disable the running of these scripts of course. Cross compiling is not an issue at all since the script is not compiled and is just executed using ash or bash if you have chosen to build bash package into your buildroot setup.

share|improve this answer
    
No I just wanted to have the script on my target, to make it run whenever I want, not only as init. And so I have to cross-compile the image (!) where I included my script as part of the file system. –  user3085931 Jan 22 at 12:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.