LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   shell scripts to binaries = possible? (http://www.linuxquestions.org/questions/linux-software-2/shell-scripts-to-binaries-%3D-possible-558305/)

jhwilliams 06-01-2007 09:55 AM

shell scripts to binaries = possible?
 
Is there any way to "compile" a shell script into a binary?

TB0ne 06-01-2007 09:59 AM

There's only one thing I could find to do something like this:

http://directory.fsf.org/devel/shell/shc.html

Although, from past experiences, it's far better to port your code to another language, rather than use one of these tools.

SharpyWarpy 06-04-2007 07:12 AM

Pardon me for asking but what are the advantages of converting a script to binary? Does it run faster?

jhwilliams 06-04-2007 09:05 AM

Motivation for this
 
My initial reason for wanting to do this was to move a bunch of scripts out of my home dir into a usr binary folder, and wouldn't feel good about myself unless they were legit binaries. Motivation = aesthetic, not functional. I suppose if this could be done well, though, it might also have some performance gains?

theYinYeti 06-04-2007 09:13 AM

Nowadays, many commands are actually wrapper scripts. Be curious and you'll find them. There's nothing wrong with having scripts in the system PATH.

The only reason I could see for such a convertion would be to allow setting the SUID bit on some of your "scripts", since this bit is ignored on real scripts.

Yves.

pixellany 06-04-2007 09:14 AM

An application written in a compiled language--eg C--will, in principle, be faster than one written in an interpreted language (includes shell scripts). In practice, the difference will not always be significant.

Assuming that there is some utility that turns a shell script into a binary, I would expect it to be slower than either option above.

Wanting to make it a binary just so it can exist happily in /xxx/bin makes NO sense. The only reason for any executable file to exist is if it does something useful for you. Assuming that it does, then why would anyone care what was inside that file? (Or what directory it was in)

OTOH, if the script is too slow, warm up the C compiler and write something that does what you need.


All times are GMT -5. The time now is 03:57 PM.