LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   creating a new binary (https://www.linuxquestions.org/questions/linux-newbie-8/creating-a-new-binary-854415/)

r_s 01-05-2011 01:09 PM

creating a new binary
 
I need to change the functions of some linux commands. We can't edit the binary files provided in /bin, is there any other method other than alias.
For ex. - I need to change the function chmod so that it takes only three consecutive integers as input (chmod 777 filename) and nothing else ?
Do I have to write by own code for it, or is there any other alternate method.

markush 01-05-2011 01:23 PM

I think it would be better you describe what you want to achieve. I don't think that writing your own commands is a good Idea.

Markus

Reuti 01-05-2011 01:24 PM

What's so bad with the original command? You could define a function and hide it from the user. Inside the function you can check for the proper arguments and call the real binary:

Code:

$ function chmod { echo "Hello"; }
$ chmod
Hello

Be aware, that either the user could still call the original command, or even install his own version.


All times are GMT -5. The time now is 06:50 PM.