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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:35:55+00:00 2026-06-11T16:35:55+00:00

In ruby script we can pass parameter like this in console: `ruby r3.rb sam

  • 0

In ruby script we can pass parameter like this in console:

 `ruby r3.rb sam sou "samarth pandey"`

this will receive in a array but now i want to send parameter like this

 `ruby sam sou {:sam => abc, :sou => abc}`

So how can i do this i don’t want to make my hash as string like

 `ruby sam sou "{:sam => abc, :sou => abc}"`
  • 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-11T16:35:56+00:00Added an answer on June 11, 2026 at 4:35 pm

    There is no way to pass the hash without quotes, because the shell would recognize > as an output redirection and pipe the output of your script into a file called abc}.

    EDITED:

    With the Ruby 1.9 Hash syntax you could do something like this:

    foo.rb:

    p eval(ARGV.join(' ').gsub(/: (.+?)([,|}])/, ': "\1"\2'))
    

    In the shell:

    $ ruby foo.rb {lkj: dssd, kjdsh: kldiu} #=> {:lkj=>"dssd", :kjdsh=>"kldiu"}
    

    I think this is not very elegant nor is the syntax valid Ruby since the quotes of the values are missing, but it would be a solution for your task.

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

Sidebar

Related Questions

On windows, I can run my ruby script like this: > ruby myscript.rb but
Can anyone explain why this happens? mybox:$ ruby script/console Loading development environment (Rails 2.3.5)
I would like to create a ruby script that I can run mysql commands
I'm looking for solution how can run Ruby script without invoking it directly like
Can we reference an array from one ruby script to another and access array
I am trying to pass an array to a ruby script from a command
I wrote a small ruby script that generates an array like the one below:
I need some help with a Ruby script I can call from the console.
I'm trying this in ruby. I have a shell script to which I can
I have Ruby script that creates a proxy so that I can make HTTP

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.