Hi All,
I am not able to see the output of $1 variable as I am passing in below script:--
Code:
#!/bin/bash -xv
echo "Enter ur password"
+ echo 'Enter ur password'
Enter ur password
read pw
+ read pw
dbaguest
echo "Enter username"
+ echo 'Enter username'
Enter username
read usrnm
+ read usrnm
password
echo "enter ip addr"
+ echo 'enter ip addr'
enter ip addr
read ip
+ read ip
192.168.12.1
while [ $# -ne 0 ]
do
echo $1
shift
done
+ '[' 0 -ne 0 ']'
echo "logging in to the server"
+ echo 'logging in to the server'
logging in to the server
ssh $2/$1@$3
+ ssh /@
ssh: : host/servname not known
echo "success"
+ echo success
success
exit 0
+ exit 0
Please suggest me some way out.
Regards,
Manish
Moderator's Comments:
Please start using code tags, and a more descriptive subject title
Because $1,$2 and $3 contains nothing in your case.
these the special variable used when you pass values as the command line arguments while executing script. and I guess you are not passing anything instead expecting from user to type the username, passwd and hostname.
when you reading the values these are automatically defined the the variable which you are passing in the read ( usrnm, pw and ip ) in your case.
so try replacing $1,$2 and $3 with $pw, $usrnm and $ip respectively.
Code:
#!/bin/bash -xv
echo "Enter ur password"
read pw
echo "Enter username"
read usrnm
echo "enter ip addr"
read ip
echo "logging in to the server"
ssh ${usrnm}/${pw}@${ip}
echo "success"
exit 0
#!/bin/bash -xv
echo "Enter ur password"
+ echo 'Enter ur password'
Enter ur password
read pw
+ read pw
dbaguest
echo "Enter username"
+ echo 'Enter username'
Enter username
read usrnm
+ read usrnm
password
echo "enter ip addr"
+ echo 'enter ip addr'
enter ip addr
read ip
+ read ip
192.168.12.1
while [ $# -ne 0 ]
do
echo $pw
shift
done
+ '[' 0 -ne 0 ']'
echo "logging in to the server"
+ echo 'logging in to the server'
logging in to the server
ssh $usrn/$pw@$ip
+ ssh /@
ssh: : host/servname not known
echo "success"
+ echo success
success
exit 0
+ exit 0
Hi ,
Below script is not working as expected.It is timing out while it is trying to log to the server using ssh.Password is correct but I am not sure how password is going to be sent using expect module.Please let me know if any syntax error is there in my script.
Code:
#!/bin/bash -xv
username="dbaguest"
echo "Enter your password:"
read newPassword
cat ssh.csv | while read line;
do
username=`echo $line | cut -d, -f1`
addr=`echo $line | cut -d, -f2`
paswd=`echo $line | cut -d, -f3`
echo "$username,$addr,$paswd"
cct=$(./test.exp $paswd $newPassword $addr $username)
if [[ "$cct" == *login* ]]; then
echo "SSH Connection to $host succeeded" >> testlog
if [[ "$cct" == *successfully* ]]; then
echo "Password has been changed successfully for $host" >> testlog
else
echo "Password change failed for $host." >> testlog
echo "$host,$addr,$paswd" >> errorlog
fi
else [[ "$cct" == *Permission* ]]
echo "$host,$addr,$paswd" >> errorlog
fi
cct=""
done
Hi there
please have a look at the code..i want to create Using a named pipe. Run a find in the background starting in the working directory
While this is happening wait for input from the user to ask him which file to find.
If the user does not enter any data in 10 seconds ask the user again.... (1 Reply)
Hi, if in a network there are lots of PCs connected with either windows or linux as operating system.Then what will be the shell script for the same and also if the PC has linux in it then we have to find if it is occupied or unoccupied.
If the PC has windows in it then we have to find if it is... (6 Replies)
Hey I have a data in the file named as outputFile.txt. The data is in the format
123456,12345678912345,400,09/09/09,INACTIVE.
I want this output without commas ie
12345612345678912345400090909INACTIVE.
Please tell me what to do and clear explain all the terms, as I am new to it. (6 Replies)
Gents,
I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
I just upgraded to Android 2.2 from 2.1. The GPS issue that was troublesome in 2.1 seems to have been fixed. Some of web browsing seems faster, but it could just be my connection is better today ;) Flash works in some browsers but not very good and it is too slow for Flash apps designed for... (0 Replies)
Hi all,
I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first.
Can you please help me determine which one to... (14 Replies)
Hi
How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)