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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:07:39+00:00 2026-05-27T13:07:39+00:00

Aliases below for running sunspot in the background work Aliases below for finding and

  • 0

Aliases below for running sunspot in the background work
Aliases below for finding and killing those instances work
ENV variables for the sunspot ports are accessible
But,
Functions for running sunspot, processing command, and killing sunspot only work after I source .bashrc outside of the function.

$user_id is set before this
sunspot_ports() gets called and prints properly when first logging in
rebash is an alias for source ~.bashrc

I have aliases for development and production as well – this is just representative code.

sunspot_ports ()
{  
  #alias sunspot_run_test to the user's port
  sunspot_test_port=$(($user_id +5300))
  echo "Your sunspot test port: $sunspot_test_port"
  alias sunspot_run_test="RAILS_ENV=test sunspot-solr run -p${sunspot_test_port} &"
  alias sunspot_kill_test="fuser -n tcp ${sunspot_test_port} -k"

  export sunspot_production_port sunspot_development_port sunspot_test_port
}

solr_test()
{
  #only makes the aliases be recognized when it is outside the function
  #rebash
  #aliases not recognized without a rebash prior to the function 
  sunspot_run_test
  #commands not recognized even with rebash
  #"RAILS_ENV=test sunspot-solr run -p${sunspot_test_port} &"
  sleep 10;
  "$@";
  sunspot_kill_test;
  #commands not recognized even with rebash
  #"fuser -n tcp ${sunspot_test_port} -k"
}

I tried sourcing .bashrc inside the function, replacing the alias with the expanded command, and putting the function inside of sunspot_ports() in every combination. The sunspot port prints out correctly when I log in, so I know that this code gets run.

Also, I need to have this as a function in .bashrc instead of somewhere in my jruby code since the jvm doesn’t allow forking (otherwise I would just use sunspot-solr start and sunspot-solr end in my spec tests)

  • 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-27T13:07:40+00:00Added an answer on May 27, 2026 at 1:07 pm

    bash will only resolve the alias if it is already defined at the time that the function invoking is initially sourced. However, in your case, the alias is defined in a function (sunspot_ports), and that function has not been run by the time solr_test is sourced.

    You have a couple of options:

    1. Invoke sunspot_ports before defining solr_test
    2. Replace your aliases with functions, e.g.,
    sunspot_kill_test()
    {
       user -n tcp ${sunspot_test_port} -k
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get template aliases to work on clang but it doesn't work
How to write joins in django,i have gone through below django documentation ,but joins
I'm not sure what's happening here, but I'm running MAMP 1.9 on MAC OS
Possible Duplicate: makefile aliases Please explain $@ $^ in the makefile below LIBS =
Can we use aliases with insert into syntax? None of the following work: INSERT
It looks like those aliases are not loaded properly. I'm using Rails 3.X, rspec
I'm trying to perform a group by action on an aliased column (example below)
C++ 0x has template aliases (sometimes referred to as template typedefs). See here .
I have put some aliases in my .bashrc to open a group of project
How do i create aliases in c# Take this scenario class CommandMessages { string

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.