1

I was working on a script that logs in to UAT server, reroute to necessary folder and activates the virtual environment.

Following is the script:

function gotouat(){
    branch=`getBranchName`;
    echo "Logging into uat for branch $branch";
    ssh -t uat "cd ../projects/$branch && source envproj/bin/activate; zsh";
}

This script reroutes to the necessary branch, but does not start virtual environment.

Following are the debug logs:

debug1: Sending command: cd ../projects/test-branch && source envproj/bin/activate; zsh

debug2: channel 1: request exec confirm 1

debug2: callback done

debug2: channel 1: open confirm rwindow 0 rmax 32768

debug2: channel_input_status_confirm: type 99 id 1

debug2: PTY allocation request accepted on channel 1

debug2: channel 1: rcvd adjust 2097152

debug2: channel_input_status_confirm: type 99 id 1

debug2: exec request accepted on channel 1

Any help would be appreciated! Also this is my first post, so apologize for any missing information/issues.

Thanks!

Rajesh
  • 111
  • 4
  • Did you try to provide full path to `zsh`? – user1700494 Apr 11 '16 at 11:26
  • Yes. I tried that. I even tried using `&&` instead of 2 commands but no luck. – Rajesh Apr 11 '16 at 11:30
  • So, in your case `zsh` is not starting at all, right? – user1700494 Apr 11 '16 at 11:33
  • No. zsh is starting but virtual environment for project is not starting. So I have to rerun `source envproj/activate/bin` – Rajesh Apr 11 '16 at 11:38
  • `source` loads and runs the content of a file in the current shell session. The `zsh` statement from your function creates a new session. Starting an interactive `zsh` *and* passing a script to run is not possible without some extra work. [This post on the ZSH mailing list](http://www.zsh.org/mla/users/2005/msg00599.html) shows one way, there might be others. – Adaephon Apr 11 '16 at 12:29
  • @Gilles Um, why is this marked as an exact duplicate, when this question is about `zsh` and the other about `bash`? Also the answer to the supposed original question employ mechanisms `zsh` does not have (`--rcfile`) or will probably not work with `virtualenv` (`SendEnv`). – Adaephon Apr 12 '16 at 04:51
  • @Adaephon Sorry, I'd missed the bit about virtualenv, reopened. – Gilles 'SO- stop being evil' Apr 12 '16 at 07:23

0 Answers0