theDaveTheRave
March 1st, 2011, 01:04 PM
Hi all,
First off the description of this thread is not good, but I can't think of a better one... so appologies.
I'm writing a pair of shell scripts to ease my wake on lan and SSH process.
The wake on lan script works fine, so now I'm having a go at my SSH script.
here is my code
#!/bin/bash
#options to log into server via ssh if required
#first check server is running...
ping -c 3 MyServer
#catch the ping exit code, code = 1 on error, 0 on success
if [[ $? != 0 ]];then #the spaces in the clause are required
echo WachabeServer not online
end
#if online give options...
else
login #call the login function
fi
exit
#function to login to server
function login(){
local Options="SSH to Server" "Quit"
select opt in $Options:do
#the first option
if[$opt="Quit"];then
echo done
exit
#will now exit from script
#second option to SSH to server
elif ["$opt="SSH to Server"];then
ssh -X davem@MyServer
#catch any erroneous entries
else
clear
echo bad options
fi
}#end
I'm going to leave in my comments for good measure.
So I run this script and I get the following output
./sshToServer.sh
PING MyServer.lan (192.168.1.6) 56(84) bytes of data.
64 bytes from MyServer.lan (192.168.1.6): icmp_seq=1 ttl=64 time=0.840 ms
64 bytes from MyServer.lan (192.168.1.6): icmp_seq=2 ttl=64 time=34.1 ms
64 bytes from MyServer.lan (192.168.1.6): icmp_seq=3 ttl=64 time=6.16 ms
--- WachabeServer.lan ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.840/13.712/34.132/14.601 ms
login: Cannot possibly work without effective root
Can someone enlighten me as to what that error message means?
I'm guessing also that I need to run the SSH part of the script (line 31) in another terminal, is that my problem? However I can't find how to do this :confused:
I assume this as otherwise the command to ssh to my server will run in the current terminal and then the script will terminate, which obviously isn't what I want, so how do I get it to do that?
Your help is appreciated.
David
First off the description of this thread is not good, but I can't think of a better one... so appologies.
I'm writing a pair of shell scripts to ease my wake on lan and SSH process.
The wake on lan script works fine, so now I'm having a go at my SSH script.
here is my code
#!/bin/bash
#options to log into server via ssh if required
#first check server is running...
ping -c 3 MyServer
#catch the ping exit code, code = 1 on error, 0 on success
if [[ $? != 0 ]];then #the spaces in the clause are required
echo WachabeServer not online
end
#if online give options...
else
login #call the login function
fi
exit
#function to login to server
function login(){
local Options="SSH to Server" "Quit"
select opt in $Options:do
#the first option
if[$opt="Quit"];then
echo done
exit
#will now exit from script
#second option to SSH to server
elif ["$opt="SSH to Server"];then
ssh -X davem@MyServer
#catch any erroneous entries
else
clear
echo bad options
fi
}#end
I'm going to leave in my comments for good measure.
So I run this script and I get the following output
./sshToServer.sh
PING MyServer.lan (192.168.1.6) 56(84) bytes of data.
64 bytes from MyServer.lan (192.168.1.6): icmp_seq=1 ttl=64 time=0.840 ms
64 bytes from MyServer.lan (192.168.1.6): icmp_seq=2 ttl=64 time=34.1 ms
64 bytes from MyServer.lan (192.168.1.6): icmp_seq=3 ttl=64 time=6.16 ms
--- WachabeServer.lan ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.840/13.712/34.132/14.601 ms
login: Cannot possibly work without effective root
Can someone enlighten me as to what that error message means?
I'm guessing also that I need to run the SSH part of the script (line 31) in another terminal, is that my problem? However I can't find how to do this :confused:
I assume this as otherwise the command to ssh to my server will run in the current terminal and then the script will terminate, which obviously isn't what I want, so how do I get it to do that?
Your help is appreciated.
David