- def check_mount_nfs_1(ip,path)
- rtn = `/bin/ping -q -c 1 #{ip}`
- if $?.exitstatus == 0
- rtn = `/sbin/showmount -e #{ip}`
- if $?.exitstatus == 0
- lines = rtn.split(/\\n/)
- for line in lines do
- if line.start_with?(path)
- return true
- end
- end
- end
- end
- return false
- end
- def check_mount_nfs_2(ip,path)
- require 'ping'
- result = Ping.pingecho(ip, 10)
- if result
- rtn = `/sbin/showmount -e #{ip}`
- if $?.exitstatus == 0
- lines = rtn.split(/\\n/)
- for line in lines do
- if line.start_with?(path)
- return true
- end
- end
- end
- end
- return false
- end
- #该片段来自于http://www.codesnippet.cn/detail/090520133214.html
来源: http://www.codesnippet.cn/detail/090520133214.html