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

  • Home
  • SEARCH
  • 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 7558103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:17:22+00:00 2026-05-30T12:17:22+00:00

This shell script creates a standalone Clojure executable, and it works. However, it relies

  • 0

This shell script creates a standalone Clojure executable, and it works. However, it relies on a second script file, jar_exec.

I would like the first script not to rely on the second script, but I am having difficult simulating the cp command.

How do I write

exec java -jar $0 "$@" 

into the stand-alone executable without relying on a second file that contains this information?

Here is the main script that works as it now stands.

#!/bin/bash
# clj_exec
# Charles M. Norton 02/28/2012
# Creates a Clojure stand-alone executable.
#
# Change History:
#
# $Log$
#

if [ 2 -ne $# ]; then
    echo "Usage: clj_exec ex-path jar-path"
    exit -1
fi

cp ~/bin/jar_exec ${1}
cat ${2} >> ${1}

Here is jar_exec, which I would like to be written directly from the first script, rather than the first script relying on a second script.

#!/bin/bash
# jar_exec
# Charles M. Norton 1/7/2012
#
# Change History:
# $Log: jar_exec,v $
# Revision 1.1  2012/01/07 22:17:49  cvsuser
# jar creator for lein and other stuff.
#
#

exec java -jar $0 "$@"
  • 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-05-30T12:17:23+00:00Added an answer on May 30, 2026 at 12:17 pm

    You could use “here documents” like this:

    #!/bin/bash
    cat > ${1} << 'EOF'
    #!/bin/bash
    # this is the content of jar_exec
    exec java -jar $0 "$@"
    EOF
    
    chmod +x ${1}
    cat ${2} >> ${1}
    

    This means: The stuff between << 'EOF' and EOF is the input to the cat command. This input is written to ${1}. This file is made executable then. And the jar is appended to that (as in the prev. solution).

    Note: For brevity I’ve omitted the argument checking.

    Edit:

    However: Why would you do this strange stuff, when Linux and any other modern Unixoid can execute jar files right away? Just make the jar executable and run it like any other command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a Shell Script, and I have a file like this called expressions.txt
A really simple shell script question. I have a file with something like this:
I am writing a shell script that takes file paths as input. For this
I am working on a Bash shell script that does something like this: #!/bin/bash
This works (prints, for example, 3 arguments): to run argv do shell script echo
How would look like a simple script ( cmd.exe batch, *nix shell , perl
I have two shell scripts. One script dynamically creates the call to the second
I'm trying to write a powershell script that creates an Exchange Mailbox. This works
For testing purposes I have this shell script #!/bin/bash echo $$ find / >/dev/null
This is a crude korn shell script that someone else wrote. I don't know

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.