I have a url array. I want to open them, and if they open without any errors, show the status, because the work has not yet been started. How can I get the desired result mentioned below by deleting all other messages from the current output.
#!/bin/ksh urlArray=('http://url1:port1' 'http://url2:port2' 'http://url3:port3') for url in "${urlArray[@]}" do result=`curl $url | head -1` if (echo $result | grep '<?xml' >/dev/null 2>&1); then echo Running else echo Not Running fi done
Current script output
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 12980 0 12980 0 0 711k 0 --:--:-- --:--:-- --:--:-- 0 Running curl: (6) Couldn't resolve host 'url2:port2' Not Running curl: (6) Couldn't resolve host 'url3:port3' Not Running
Desired conclusion:
Running Not Running Not Running
source share