Hi guys this is my first foray into shell scripting. Thought I would try something easy but also something I could actually use, so I tried to make a remote session launcher. Having trouble processing the command-line arguments it seems. If I pass no arguments it works but if I pass an argument it always tries the first one in the list. This may make some of you cringe, but here's my code below:
Quote:
#!/bin/sh
# remote session launcher
# 2/16/04
if [ -z $1 ]
then
echo "Please enter a hostname followed by the command 'go'."
echo "Valid hostnames: " # add hosts here in addition to below
echo "foo: mattelmore.com"
echo "taki: shell.takiweb.net"
echo
exit 0
else
fi
if [ '$1 = foo' ]
then
echo "Connecting to server $1 ..."
ssh -p 5224 -l matt 204.214.213.11
exit 0
else
fi
if [ '$1 = taki' ]
then
echo "Connecting to server $1 ..."
ssh -l mattelmore shell.takiweb.com
exit 0
else
fi
|
There's more but I snipped some of it out since it's redundant. Problem is this: I type ./go foo it tries to connect to the foo server from the first if/fi loop. If I type ./go taki it tries to connect to foo.
Appreciate any input!