I have recently finished a script that will ask for a hostname and automatically take the argument of the function
and ssh
into one of my work servers.
Here is a copy of my script:
#!/bin/bash
echo "Provide hostname: "
read host
createSSHFunction()
{
arg1=$1
ssh $host
}
createSSHFunction $host
while((1)); do ~/sshScript.sh; done
What I notice though is say I want to ssh
into one of the servers and I got disconnected, by instinct I will press the Up arrow key to redisplay the same argument I put in the last time. Here is an example of that:
Provide hostname:
crf-alpha
support@localhost's password:
Last login: Thu Jul 24 12:16:33 2014 from localhost
[support@crf-alpha ~]$
Connection to localhost closed.
Provide hostname:
^[[A
Is there such a way to code in my current script where it will buffer anything I type last? So for example i ssh
into the crf-alpha and I get disconnected. My script will run again prompting me to enter a hostname, I would like it so that if I press the Up arrow key, the last input I entered will re-display, so in this case crf-alpha rather than the weird symbol I always get.
rlwrap
– user000001 Jul 24 at 16:30sudo
access. I figured there may be something built-in that I can use. – ryekayo Jul 24 at 16:36read
does have a-e
argument which uses the readline library, but there's no way to get it to use an alternative history buffer. – Patrick Jul 24 at 16:53