Sponsored Content
Full Discussion: Can someone please help!
Top Forums Shell Programming and Scripting Can someone please help! Post 302216101 by nua7 on Friday 18th of July 2008 02:45:40 AM
Old 07-18-2008
Hi!
since this is my first script using arrays and user input, I am facing too many problems.

In the script below, even if I enter "done" as a hostname , it still continues to go further and ask username and password.

Code:
#!/usr/bin/sh
##Take input from the user
c=d=e=0
while [ "$host_name" != done ] 
do
  echo "Please enter the host_name"
  read host_name
  store_hostname[$c]=$host_name
  c=$(( c + 1 ))
  echo "Please enter the username"
  read username
  echo $username
  store_username[$d]=$username
  d=$(( d + 1 ))
  echo "Please enter the password"
  read password
  echo $password
  store_password[$e]=$password
  e=$(( e + 1 ))
done
for i in c
do
#Create a destination directory
ssh -q ${store_username[$d]}@${store_host_name[$c]} mkdir temp
#scp files to host
scp -r /root/temp ${store_username[$c]}@${store_host_name[$c]}:/root/
done

 
dsenableroot(8) 					    BSD System Manager's Manual 					   dsenableroot(8)

NAME
dsenableroot -- enables or disables the root account. SYNOPSIS
dsenableroot [-d] [-u username] [-p password] [-r rootPassword] DESCRIPTION
dsenableroot sets the password for the root account if enabling the root user account. Otherwise, if disable [-d] is chosen, the root account passwords are removed and the root user is disabled. A list of flags and their descriptions: -u username Username of a user that has administrative privileges on this computer. -p password Password to use in conjunction with the specified username. If this is not specified, you will be prompted for entry. -r rootPassword Password to be used for the root account. If this is not specified for enabling, you will be prompted for entry. EXAMPLES
-dsenableroot Your username will be used and you will be queried for both your password and the new root password to be set to enable the root account. -dsenableroot -d Your username will be used and you will be queried for only your password to disable the root account. -dsenableroot -u username -p userpassword -r rootpassword The supplied arguments will be used to enable the root account. -dsenableroot -d -u username -p userpassword The supplied arguments will be used to disable the root account. Mac OS August 08 2003 Mac OS
All times are GMT -4. The time now is 09:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy