The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
what is wrong with this tr -d? cleansing_flame UNIX for Dummies Questions & Answers 3 02-06-2008 09:34 AM
What’s wrong with the following? vrn UNIX for Dummies Questions & Answers 8 03-19-2006 06:09 PM
where have i gone wrong? Blip Shell Programming and Scripting 3 01-28-2004 01:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-25-2006
Registered User
 

Join Date: May 2006
Posts: 1
Bash Secure Shell Script

im trying to create a little script that does a secure shell login based on some input(ip address, server name, etc...)
everything in perenthesis() as been edited for privacy reasons

I cant figure out what im doing wrong? if you can post some info for me that would be awsome

------------------------The Script------------------------------
#!/bin/bash
port="22"

echo 'What server:?(server1, server2 or type ip address)'
read $server

if [ $server = "(server1)" ];
then
ssh (uname)@(ipaddress) -p(port number)
elif [ $server = "(server2)" ];
then
ssh (uname)@(ipaddress)
elif [ "$server" -eq *.*.*.* ];
then
echo 'User:?'
read $user
echo 'port:?'
ssh $user@$server -p$port
else
exit
fi

Last edited by jzocco; 05-25-2006 at 12:23 PM.
Reply With Quote
Forum Sponsor
  #2  
Old 05-25-2006
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
I don't understand - do you have a problem with the script above? Either way, it looks like you're being a bit redundant - instead of them typing in the server name, then you check if they typed in the server name, then you execute ssh with the server name, why not accept their input:
Code:
#! /bin/bash
echo -n "Enter a server name or IP address: "; read _srv
echo -n "Enter username for $_srv, or enter for \"${LOGNAME}\": "; read _usr
[[ -n $_usr ]] && _usr=${_usr}@
echo ssh ${_usr}${_srv} || {
 echo "SSH encountered an error! " >&2
 exit 1
 }
However, you may need to insert some error handling, validation, etc...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0