glad to write it for you here. I've done a lot of searching about that and haven't found a solution. What I want to do is relatively simple.
There is a caveat local bash function in my workstation environment.
function caveat(){
echo "function main caveat executing in $HOSTNAME"
function caveat_a(){
echo "function caveat_a executing in $HOSTNAME"
}
function caveat_b(){
echo "function caveat_b executing in $HOSTNAME"
}
}
And I would like do SSH into a remote host (in a interactive shell) to do some lazy sysadmin tasks there. And when I need to execute either caveat_a or caveat_b functions I would like to be able to call them there, into the remote host..
What my research revealed is that is possible to declare a local function to be available remotely and then execute it directly ... and it works fine for me. But what I need is to declare and fall into an interactive shell.
Last attempt was to include a 'bash --login' in the end of the line, as shown below:
username@localhost ~ $ caveat
function main caveat executing in localhost
username@localhost ~ $ caveat_a
function caveat_a executing in localhost
username@localhost ~ $ caveat_b
function caveat_b executing in localhost
username@localhost ~ $
username@localhost ~ $ ssh username@remote_host -t "$(declare -f caveat); caveat; caveat_a; bash --login"
Are you sure you want to continue connecting (yes/no)? yes
username@remote_host's password:
function main caveat executing in remote_host
function caveat_a executing in remote_host
username@remote_host ~ $ #nice, it executed those caveat functions as echoed above
..this way it interacts with me.. so I can execute other commands there.. but when I press 'caveat<TAB><TAB>'
my caveat is not declared there yet.
I think I'm missing something. Thanks in advance for all your help and answers.
If possible, it seems better to use vanilla solution as simple as possible (without expect, without other binaries).
Thanks