How to supply the password in a ping command ?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to supply the password in a ping command ?
# 1  
Old 05-15-2009
How to supply the password in a ping command ?

for i in $var; do
for j in $var; do
if [ ! $i == $j ]
then
ssh -x -a "$host_login_name"@${i} ping -c 3 -s 3 ${j}
if [ $? -eq 0 ]
then
printf "Success\n"
else
printf "Failed\n"
fi
fi
done
done



Enter your box login user name : balvijay
Password:
PING xxxxxxxx.xxxxxxxxx.com (140.85.136.28) 3(31) bytes of data.
11 bytes from xxxxxxxx.xxxxxxxxx.com (140.85.136.28): icmp_seq=0 ttl=64
11 bytes from xxxxxxxx.xxxxxxxxx.com (140.85.136.28): icmp_seq=1 ttl=64
11 bytes from xxxxxxxx.xxxxxxxxx.com (140.85.136.28): icmp_seq=2 ttl=64

--- xxxxxxxx.xxxxxxxxx.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
, pipe 2
Success

Password:
PING yyyyyyy.yyyyyyyy.com (140.85.136.23) 3(31) bytes of data.
11 bytes from yyyyyyy.yyyyyyyy.com (140.85.136.23): icmp_seq=0 ttl=64
11 bytes from yyyyyyy.yyyyyyyy.com (140.85.136.23): icmp_seq=1 ttl=64
11 bytes from yyyyyyy.yyyyyyyy.com (140.85.136.23): icmp_seq=2 ttl=64

--- yyyyyyy.yyyyyyyy.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
, pipe 2
Success

I need to supply the password in the ssh line so that it does not ask from the command prompt,
and I like to supress the ping byte details.

How to do this ?
# 2  
Old 05-15-2009
search for the tool "expect" to make interactive scripts...
# 3  
Old 05-15-2009
Or search for password-less SSH which has been covered here before.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with Ping command.

Hi, I have a shell script, that has to run in putty for days together. So , I need to keep the network server connection alive and running. The execution of shell script shouldn't be interrupted as it produces undesirable results. Can anyone provide me with a script ? (3 Replies)
Discussion started by: angie1234
3 Replies

2. UNIX for Dummies Questions & Answers

Help on ping command

Hi, I have a list of 500 IP address and need to ping all the IP address. I had written a script to do this and its working if the IP is valid one. If any invalid IP present, the process got hang up. Also I have tried with -c , -I and -w options, its not working. Any one help me on this... (2 Replies)
Discussion started by: Rksiva
2 Replies

3. AIX

Problem with 'ping' command

Hi All, I'm testing ping command on two servers. A,B,C,D are servers From A-->B: ping -c 3 -p ff -s30720 <B IP-Addres> This works fine. From C-->D: ping -c 3 -p ff -s30720 <D IP-Addres> This is NOT working and 100% packe loss :( But if I use 8700 instead of 30720 for packet size... (6 Replies)
Discussion started by: saraperu
6 Replies

4. UNIX for Dummies Questions & Answers

help in PING and traceroute command

i cannot find a usefull ping and traceroute command from TCP to another TCP server with port. I usually do only traceroute IP and ping IP..is that enough? I wanted to check its connectivity to an IP address with port.. example: from ip 1.1.1.1 (TCP port 1234) destination 2.2.2.2 (TCP... (1 Reply)
Discussion started by: lhareigh890
1 Replies

5. Shell Programming and Scripting

supply password to scp with out interacting

Hi, I am trying to supply password to scp with out having manual interaction. Like, store the password in a variable and it should be supplied to the scp when it prompted for the password. Is there any other way than the user authentication and using "expect" in perl script. i.e is this... (3 Replies)
Discussion started by: pc_raghu
3 Replies

6. Shell Programming and Scripting

tcl command to supply a carriage return

I have a java program that runs on a unix server that prompts the user for input and provides a default value to the user. So it does something like this: Enter source server name <source_server_name>: Enter target server name <target_server_name>: I just hit enter to take the default... (1 Reply)
Discussion started by: progkcp
1 Replies

7. AIX

Supply Password Thru Script

Hello, I am using AIX 5 and one of the application does certain db updation daily and runs few script. One script among them calls another program, which in turn asks for a user Id and password. Is there anyway to use 'expect' of something similar on AIX so that while calling that program of... (1 Reply)
Discussion started by: panchpan
1 Replies

8. UNIX for Dummies Questions & Answers

Ping command

Hello Everybody: Im the root of the system, I need to grant some limited priviliges user an acess to the ping command so he can ping some IPs with his script. should I add the command to his path?? or what?? Thanks a lot (3 Replies)
Discussion started by: aladdin
3 Replies

9. IP Networking

About ping command

Hi! I have small problem. I want to ping a server and the result shouldn't be printed in the browser window, just become a value. Here you can see the script that I have: $command="ping linux.com -t ttl -c1 | tail -1 | awk '{print $4 \" \" $5}'"; $output = system($command); ... (2 Replies)
Discussion started by: Papa Deoo
2 Replies

10. UNIX for Dummies Questions & Answers

About ping command

Hi! I have small problem. I want to ping a server and the result shouldn't be printed in the browser window, just become a value. Here you can see the script that I have: <? $command="ping linux.com -t ttl -c1 | tail -1 | awk '{print $4 \" \" $5}'"; $output = system($command);... (1 Reply)
Discussion started by: Papa Deoo
1 Replies
Login or Register to Ask a Question