Skip to content

Instantly share code, notes, and snippets.

@jawspeak
Created January 5, 2010 22:25
Show Gist options
  • Select an option

  • Save jawspeak/269801 to your computer and use it in GitHub Desktop.

Select an option

Save jawspeak/269801 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
env=$1
user=somebody
case $env in
# with help from http://serverfault.com/questions/70482/how-can-i-remotely-log-on-to-a-machine-execute-a-script-which-sets-up-an-environ
machine01)
dir=/opt/tomcat/servers/env-a-1/webapps/foo/
;;
machine02)
dir=/opt/tomcat/servers/env-b-1/webapps/foo/
;;
svc01)
dir=/opt/services/dotcom/Foo/3_0_0/
;;
svc02)
dir=/opt/services/dotcom/Foo/3_0_0/
;;
*)
echo "cat me for help using"
exit 1
esac
remote_cmd="hostname; cd $dir; pwd; /bin/bash -l -i"
cmd="ssh -t -t -o StrictHostKeyChecking=no $user@$env $remote_cmd"
echo "will run: $cmd"
exec $cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment