简体   繁体   中英

SSH + Rails: Run Rails (and Capistrano) commands with ssh session in one line

I want to know if there's a way to do like

ssh user@host "cap production rails:console"

where host is my Rails development environment, and then be able to use the remote console.

When I try that command, it shows: bash: cap: command not found

Then I tried to run

ssh user@host "bundle exec cap production rails:console"

but it shows bash: bundle: command not found

Note that I use rvm .

My .bashrc (excerpts):

....
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

...

#linuxbrew
export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable 
change. export PATH="$PATH:$HOME/.rvm/bin"

# for transcriber service
export SOUNDNOTATION_TRANSCRIBER_BINARY_PATH="$HOME/transcriber/SoundnotationTranscriber"
# sidekiq
export TRANSCRIPTION_API_HOST_PORT='localhost:4040'

# wkhtmltopdf
export WKHTMLTOPDF="/home/soundnotation/.rvm/gems/ruby-2.3.1/bin/wkhtmltopdf"

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

Have you tried to use full path to cap:

ssh user@host "/Users/anton/.rvm/gems/ruby-2.3.1@gotoweb/bin/cap production rails:console"

?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM