Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: vishrut_n_shah on February 17, 2011, 03:27:33 AM

Title: Where is the defination of internal commands ?
Post by: vishrut_n_shah on February 17, 2011, 03:27:33 AM
Hello ,

         I want to know that which file contains defination for internal commands like ls,cat,rm,mkdir ???

         Can i make my own commands that will be run just like internal shell commands ??

Please reply...

Thanks in advance ..  :)
Title: Re: Where is the defination of internal commands ?
Post by: Rich on February 17, 2011, 03:35:54 AM
Hi vishrut_n_shah
Open a terminal and type busybox for a list of commands. You can make your own
commands by writing a script.
Title: Re: Where is the defination of internal commands ?
Post by: vishrut_n_shah on February 17, 2011, 04:38:31 AM
Yes i found all the commands...

But when i opened file it shows some  stars and boxes...

Exactly where to i write script for my own command?? :)

Thanks
Title: Re: Where is the defination of internal commands ?
Post by: tinypoodle on February 17, 2011, 04:42:05 AM
Code: [Select]
ls -l `which <command>`
shows the path of an external command.

Internal shell commands are compiled into the shell at build time.

Shell scripts rely on calling existing commands.

HTH
Title: Re: Where is the defination of internal commands ?
Post by: Rich on February 17, 2011, 04:44:07 AM
Hi vishrut_n_shah
Busybox is a compiled program, not a script, you cannot edit it. You could create a
directory under your home directory for scripts and then add it to your path.
Title: Re: Where is the defination of internal commands ?
Post by: vishrut_n_shah on February 17, 2011, 05:03:42 AM
Hi rich ,

          Ok. I understand that.But Is there any way so that i can build my commands and they will be comipled at compile time like internal commands.

          I think there is a defination or code behind every internal commands.Am i right? if yes then i want to just refer that code.Is ther any way to get it??


Thanks
Title: Re: Where is the defination of internal commands ?
Post by: Rich on February 17, 2011, 05:34:15 AM
Hi vishrut_n_shah
I'm not sure of what you are trying to do. Is there any special command you are looking
for? Can you give a specific example of what you would like to do? Unless you know
how to write programs in C, scripting is really the right way to go. The calc command
in /usr/bin for example is a script.
Title: Re: Where is the defination of internal commands ?
Post by: vishrut_n_shah on February 17, 2011, 06:03:15 AM
Hi Rich ,

          I am just trying to embed my command to the list so that i can complete my project. And i know the programing in C infect i am an IT Engineer...

For example if i have written my own find command to find some specific file from the entire directory. then how i will make it executable just as like ls .

Do you understand my problem??

Please reply .. If it requires C programming i can handle that one very smoothly.

Thanks in advance
Title: Re: Where is the defination of internal commands ?
Post by: tinypoodle on February 17, 2011, 06:07:51 AM
Hi rich ,

          Ok. I understand that.But Is there any way so that i can build my commands and they will be comipled at compile time like internal commands.

          I think there is a defination or code behind every internal commands.Am i right? if yes then i want to just refer that code.Is ther any way to get it??


Thanks

The source code of busybox
Title: Re: Where is the defination of internal commands ?
Post by: vishrut_n_shah on February 17, 2011, 06:19:22 AM
Hello tinypoodle,

                         So i have to make changes in source code of Busybox ??
Thanks
Title: Re: Where is the defination of internal commands ?
Post by: Rich on February 17, 2011, 06:31:52 AM
Hi vishrut_n_shah
Now we are getting somewhere. If you write your own find command for example,
just place it in the /usr/local/bin directory and the operating system will use your
find command instead of it's own. If you write your command in C then you can use
the compiletc application to compile it, if you write a script file then you just
chmod 755 yourfilename to make it executable.
Title: Re: Where is the defination of internal commands ?
Post by: tinypoodle on February 17, 2011, 06:34:10 AM
Hello tinypoodle,

                         So i have to make changes in source code of Busybox ??
Thanks

That would be if you want to modify internal commands of the shell yes, as the default shell in TC is ash, which is part of busybox.

http://www.busybox.net/FAQ.html might help you understand much better
Title: Re: Where is the defination of internal commands ?
Post by: vishrut_n_shah on February 17, 2011, 06:34:35 AM
Thanks a lot Rich & Tinypoodle.... I'll do it.. Thanks
Title: Re: Where is the defination of internal commands ?
Post by: vishrut_n_shah on February 17, 2011, 07:22:29 AM
First of all Thanks for your help....

I tried it and working fine. .

But it's a temporary... actually i have TinyCore in Flash drive.. so i have to make it at every time ???

Is there any way to make it permanent ?

Thanks
Title: Re: Where is the defination of internal commands ?
Post by: vishrut_n_shah on February 17, 2011, 07:48:03 AM
Hello ,

       Please help me to make it permanent ??  ???

Thanks
Title: Re: Where is the defination of internal commands ?
Post by: Rich on February 17, 2011, 08:03:14 AM
Hi vishrut_n_shah
Open the file  /opt/filetool.lst. Add a line for each command you want to save.
For example:

usr/local/bin/command1
usr/local/bin/command2
etc....

When you shut down and backup your files will be saved, when you restart they will be restored.

Title: Re: Where is the defination of internal commands ?
Post by: combo3 on February 17, 2011, 10:22:37 AM
A better option is to create /home/tc/.local/bin and put all your personal scripts/binaries there.

Code: [Select]
mkdir -p /home/tc/.local/bin
Then you won't have to keep adding new commands to /opt/.filetool.lst
Title: Re: Where is the defination of internal commands ?
Post by: Rich on February 17, 2011, 11:00:40 AM
In that case you might also want to suggest that he add  PATH=/home/tc/.local/bin:$PATH
to his /opt/bootlocal.sh file.
Title: Re: Where is the defination of internal commands ?
Post by: gerald_clark on February 17, 2011, 11:07:19 AM
bootlocal.sh cannot directly change a logins environment.
The users .profile already adds ~/.local/bin to PATH.
Title: Re: Where is the defination of internal commands ?
Post by: tinypoodle on February 17, 2011, 11:07:31 AM
In that case you might also want to suggest that he add  PATH=/home/tc/.local/bin:$PATH
to his /opt/bootlocal.sh file.

Code: [Select]
grep -A 2 local /etc/skel/.profile
 ;)