I want to execute a script portion after a successful ssh connection has been established. I'd like to make it easier for me to tail a log file with a script I am trying to write.
Here is the script work in progress:
echo "[Log Tunnel]"
if [ "$1" == "foo" ]
then
echo "connecting to foo.dev.company.net"
ssh foo.dev.company.net
tail -f var/logs/staff/backend/backend.log # what's the way to do this
fi
if [ "$1" == "bar" ]
then
echo "connecting to bar.dev.company.net"
ssh bar.dev.company.net
fi
When I run the script I expect the following:
[Log Tunnel]
connecting to foo.dev.company.net
m[email protected]'s password: ***********
# Output of Tail
I wonder if it is possible at all to have the ssh connection established and pass the subsequent shell a new script it should excecute right after startup.
Edit:
My goal is to have a following tail to a log file on a remote server in my shell. The scrip should ease the way to tail those log files my simple typing ./rtail.sh foo
.When executing that command I expect the shell to display the particular tail output depending on the remote server I've chosen by the shell argument. I just want a shortcut for:
- ssh to remote server
- tail -f path/to/logfile.log