LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-01-2007, 08:55 AM   #1
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
shell scripts to binaries = possible?


Is there any way to "compile" a shell script into a binary?
 
Old 06-01-2007, 08:59 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
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.
 
Old 06-04-2007, 06:12 AM   #3
SharpyWarpy
Member
 
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Rep: Reputation: 91
Pardon me for asking but what are the advantages of converting a script to binary? Does it run faster?
 
Old 06-04-2007, 08:05 AM   #4
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Original Poster
Rep: Reputation: 211Reputation: 211Reputation: 211
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?
 
Old 06-04-2007, 08:13 AM   #5
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
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.
 
Old 06-04-2007, 08:14 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.
 
  


Reply

Tags
binary, compile, sh, shell



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell scripts in RT nipunos Linux - Software 0 05-09-2007 02:06 AM
Shell scripts??? F_ANTHONY Programming 2 10-27-2004 06:28 PM
shell scripts... roofy Linux - Newbie 13 05-06-2003 06:06 PM
Shell scripts anon227 Linux - Software 1 01-03-2003 03:11 PM
shell scripts gui10 Programming 10 10-28-2001 02:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration