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 5839633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:36:42+00:00 2026-05-22T11:36:42+00:00

I wrote a bash wrapper to ruby that goes through various setup steps. The

  • 0

I wrote a bash wrapper to ruby that goes through various setup steps.

The most basic version is,

   #!/bin/bash 
   #   ruby_wrapper.sh
   ruby

Now I want to be able to use this wrapper just like regular ruby! Specifically, I want to create a .rb file that uses this “interpreter”.

   #!/path/to/ruby_wrapper.sh
   #  my_file.rb
   puts "hello world"

So I want to be able to do $ ./my_file.rb instead of $ ruby_wrapper.sh my_file.rb

Is this possible?

The documentation claims it isn’t.

Note that the interpreter may not itself be an interpreter script.

But I don’t see why not. Does anyone have any ideas to get around this?

  • 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-22T11:36:42+00:00Added an answer on May 22, 2026 at 11:36 am

    Try invoking your wrapper with /usr/bin/env. It’s actually good practice to execute Ruby scripts with /usr/bin/env ruby as you don’t have to hard code the path to the ruby binary, so this is not unnatural.

    $ cat ruby_wrapper.sh 
    #!/bin/bash
    exec ruby "$@"
    
    $ cat wrapped.rb 
    #!/usr/bin/env /tmp/ruby_wrapper.sh
    puts "hello world"
    
    $ ./wrapped.rb 
    hello world
    

    Also as a side note see how I’ve used exec in the wrapper script. This will allow the ruby interpreter to take over your wrapper script’s process rather than run as a child process of your script. This makes the wrapper transparent to the caller (signals will be delivered directly to ruby rather than to bash, for example).

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

Sidebar

Related Questions

I wrote a short bash script to complete a task that involves creating a
I want to write a simple bash script that will act as a wrapper
I wrote a bash script that fetches lyrics from a website. The script is
I'm trying to write a bash script that increments the version number which is
I want to write a sh/bash script that can determine whether a particular directory
I wrote a windows service using VB that read some legacy data from Visual
I wrote myself a little downloading application so that I could easily grab a
I wrote a component that displays a filename, a thumbnail and has a button
I wrote a simple tool to generate a DBUnit XML dataset using queries that
I wrote an application that currently runs against a local instance of MySql. I

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.