![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#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. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
}
|
||||
| Google The UNIX and Linux Forums |