Home > OS >  Linux under the log in the server through a script
Linux under the log in the server through a script

Time:10-06

For bosses, encounter a problem, now is I can have a network connection of the server, want to write a script on the server implementation the SSH command,./a.s h after waiting for the parameter, enter 1 is to perform the SSH 192.168.1.1, enter 2 is to perform the SSH 192.768.1.2, and can identify the current logged in user, trouble ask bosses how to write the script

CodePudding user response:

reference
read -p "please enter a number:" n
If [$n==1)
Then
SSH 192.168.1.1
Elif [$n==2]
Then
SSH 192.168.1.2 instead
The else
Echo "input is wrong, please input the number 1 or 2"
Fi


Like this, you need to log in again after do the operation, can expect to do

CodePudding user response:

reference 1st floor zhouchao6 response:
reference
read -p "please enter a number:" n
If [$n==1)
Then
SSH 192.168.1.1
Elif [$n==2]
Then
SSH 192.168.1.2 instead
The else
Echo "input is wrong, please input the number 1 or 2"
Fi


Like this, you need to log in again after do the operation, can expect to do

Understand, thank you to come, bosses
  • Related