[can be closed/deleted] Strange $? result of ping?

Moderators: mdrjr, odroid

[can be closed/deleted] Strange $? result of ping?

Unread postby fgordon » Tue Mar 21, 2017 9:43 am

I tested the result of ping... and I think it behaves really strange when testing the "$?" result

192.168.100.89 does not exist on my network and never has....

root@odroid64:~# ping -c1 192.168.100.89 | echo "$?"
0
root@odroid64:~# ping -c1 192.168.100.89 | echo "$?"
0
root@odroid64:~# ping -c1 192.168.100.89
PING 192.168.100.89 (192.168.100.89) 56(84) bytes of data.
From 192.168.100.11 icmp_seq=1 Destination Host Unreachable

--- 192.168.100.89 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

root@odroid64:~# ping -c1 192.168.100.89 | echo "$?"
1
root@odroid64:~# ping -c1 192.168.100.89 | echo "$?"
0
root@odroid64:~# uname -a
Linux odroid64 3.14.79-109 #1 SMP PREEMPT Thu Mar 16 20:05:25 BRT 2017 aarch64 aarch64 aarch64 GNU/Linux
root@odroid64:~#
GNU bash, version 4.3.46(1)-release-(aarch64-unknown-linux-gnu)


Can anyone verify this on his c2/ubuntu? I expected "1" each time for "$?"
Last edited by fgordon on Tue Mar 21, 2017 11:50 am, edited 1 time in total.
fgordon
 
Posts: 27
Joined: Mon Jan 12, 2015 6:38 pm
languages_spoken: english
ODROIDs: C1 + C2

Re: Strange $? result of ping?

Unread postby paulcrawford » Tue Mar 21, 2017 11:16 am

I got exactly the same as you using a kernel I compiled from git on 2017-03-11...

192.168.100.89 does not exist my network either.
paulcrawford
 
Posts: 102
Joined: Tue May 10, 2016 11:51 am
languages_spoken: english
ODROIDs: odroid c2

Re: Strange $? result of ping?

Unread postby fgordon » Tue Mar 21, 2017 11:48 am

Uh haha can be closed....

*g* as I use $? it of course hast to be ";" instead of "|"....

Sorry my fault ..... :o :)
fgordon
 
Posts: 27
Joined: Mon Jan 12, 2015 6:38 pm
languages_spoken: english
ODROIDs: C1 + C2


Return to Ubuntu

Who is online

Users browsing this forum: No registered users and 1 guest