Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Creating a .ELF file

    Hi all,

    Instead of creating a normal ASCII txt file with the intruction (let's say) 'ls -Z /home' and executing it, I want to make this ACII a file binnary executable ( .ELF ).
    Any suggestions? (its probably pretty basic)

  2. #2
    Linux Engineer
    Join Date
    Jan 2005
    Saint Paul, MN
    Code it in the language "C" or "C++". The "ELF" format is created via the "linker" when building a program from a compiled language (Fortran, C, C++, ADA, etc). The scripting languages such as bash, sh, python, ruby, etc are never linked and therefore not able to be converted into the ELF format. Java while you compile it, as does not linked as it is compiled to run on a "virtual machine" (the run-time system).

  3. #3
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris

    There is at least one shell-script-compiler. Look at the links for shc at Francisco Rosales, home page

    The tar file is still there as of this writing. I have an old directory that shows that I tried it once. However, I have no need of it, so apparently I deleted the translator. I have not tried to install it recently (it is a c program itself), but it appears to have been updated 2012.05.

    The documentation explains that won't see any improvement in speed.

    There are brief discussions about such tools, e.g.
    scripting - How to compile a linux shell script to be a standalone executable *binary* (i.e. not just e.g. chmod 755)? - Stack Overflow

    A Google search provides about 2M hits from phrase compile shell script

    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  4. $spacer_open
  5. #4
    Linux Engineer
    Join Date
    Jan 2005
    Saint Paul, MN
    From the shc man page:
         The compiled binary will still be  dependent  on  the  shell
         specified  in  the  first  line  of  the  shell  code  (i.e.
         #!/bin/sh), thus shc does not create completely  independent
         shc itself is not a compiler such as cc, it  rather  encodes
         and encrypts a shell script and generates C source code with
         the added expiration capability. It  then  uses  the  system
         compiler  to compile a stripped binary which behaves exactly
         like the  original  script.  Upon  execution,  the  compiled
         binary  will  decrypt and execute the code with the shell -c
         option.  Unfortunatelly, it will  not  give  you  any  speed
         improvement as a real C program would.
         shc's main purpose is to protect  your  shell  scripts  from
         modification  or  inspection.  You can use it if you wish to
         distribute your scripts but don't want  them  to  be  easily
         readable by other people.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts