Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 159

Change shells in a script function

$
0
0

I'm rocking ZSH as my main shell, but in my .zshrc, I'd like to set up a ssh command with expect so I can ssh into my dev boxes easier when I flash builds (there's literally no security needed it's all on an intranet of sorts). I can pass a password to ssh with !#/usr/bin/expect shell.

Is it kosher to do this?

password=sick_awesome_password6969function expect_ssh () {# I enter expect shell at the beginning of this function <==#!/usr/bin/expectset timeout 20set cmd [lrange $argv 1 end]set password [lindex $argv 0]eval spawn $cmdexpect "password:"send "$password\r";interactexit 0 # Then escape from it ? <==}default_boxssh_subnet=1function bosh () {    if [[ ! $1 == *"."* ]];    then        # ssh root@10.10.$default_boxssh_subnet.$1        expect_ssh 10.10.$default_boxssh_subnet.$1    else        # ssh root@10.10.$1        expect_ssh 10.10.$default_boxssh_subnet.$1    fi}

Viewing all articles
Browse latest Browse all 159

Trending Articles