Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7900893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:04:45+00:00 2026-06-03T09:04:45+00:00

First, I already googled but only found examples where a compressed file (say a

  • 0

First, I already googled but only found examples where a compressed file (say a .tar.gz) is embedded into a shell script.

Basically if I have a C program (hello.c) that prints a string, say Hello World!.

I compile it to get an executable binary

gcc hello.c -o hello

Now I have a shell script testEmbed.sh

What I am asking is if it is possible to embed the binary (hello) inside the shell script so that when I run

./testEmbed.sh

it executes the binary to print Hello World!.

Clarification:
One alternative is that I compress the executable into an archive and then extract it when the script runs. What I am asking is if it is possible to run the program without that.

Up until now, I was trying the method here. But it does not work for me. I guess the author was using some other distribution on another architecture. So, basically this did not work for me. 😛

Also, if the workflow for a C program differs from a Java jar, I would like to know that too!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:04:46+00:00Added an answer on June 3, 2026 at 9:04 am

    Yes, this can be done. It’s actually quite similar in concept to your linked article. The trick is to use uuencode to encode the binary into text format then tack it on to the end of your script.

    Your script is then written in such a way that it runs uudecode on itself to create a binary file, change the permissions then execute it.

    uuencode and uudecode were originally created for shifting binary content around on the precursor to the internet, which didn’t handles binary information that well. The conversion into text means that it can be shipped as a shell script as well. If, for some reason your distribution complains when you try to run uuencode, it probably means you have to install it. For example, on Debian Squeeze:

    sudo aptitude install sharutils
    

    will get the relevant executables for you. Here’s the process I went through. First create and compile your C program hello.c:

    pax> cat hello.c
    
    #include <stdio.h>
    int main (void) {
        printf ("Hello\n");
        return 0;
    }
    
    pax> gcc -o hello hello.c
    

    Then create a shell script testEmbed.sh, which will decode itself:

    pax> cat testEmbed.sh
    
    #!/bin/bash
    rm -f hello
    uudecode $0
    ./hello
    rm -f hello
    exit
    

    The first rm statement demonstrates that the hello executable is being created anew by this script, not left hanging around from your compilation. Since you need the payload in the file as well, attach the encoded executable to the end of it:

    pax> uuencode hello hello >>testEmbed.sh
    

    Afterwards, when you execute the script testEmbed.sh, it extracts the executable and runs it.

    The reason this works is because uudecode looks for certain marker lines in its input (begin and end) which are put there by uuencode, so it only tries to decode the encoded program, not the entire script:

    pax> cat testEmbed.sh
    
    #!/bin/bash
    rm -f hello
    uudecode $0
    ./hello
    rm -f hello
    exit
    
    begin 755 hello
    M?T5,1@$!`0````````````(``P`!````$(,$"#0```#`!@```````#0`(``'
    M`"@`'@`;``8````T````-(`$"#2`!`C@````X`````4````$`````P```!0!
    : : :
    M:&%N9&QE`%]?1%1/4E]%3D1?7P!?7VQI8F-?8W-U7VEN:70`7U]B<W-?<W1A
    M<G0`7V5N9`!P=71S0$!'3$E"0U\R+C``7V5D871A`%]?:38X-BYG971?<&-?
    4=&AU;FLN8G@`;6%I;@!?:6YI=```
    `
    end
    

    There are other things you should probably worry about, such as the possibility that your program may require shared libraries that don’t exist on the target system, but the process above is basically what you need.


    The process for a JAR file is very similar, except that the way you run it is different. It’s still a single file but you need to replace the line:

    ./hello
    

    with something capable of running JAR files, such as:

    java -jar hello.jar
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, I'd like to say that I'm already looking into the Cutting Stock
First days dealing with Perl and blocked already :) Here's the situation: a file
first of all I'm totally new to FAST but I already have a couple
First some background. I inherited a project where the build file was already written
First, yes I have searched already and found this answer already: GWT JSNI -
I just published my first app and already there are a bunch of mistakes
I have a nested php array. I have the first select populated already. I
First a little background: I have already managed to connect to a Microsoft SOAP
First. I know that there already exists a variety of topics on how to
First of all: I do know that there are already many questions and answers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.