# Telnet errors coming on screen while using snarf command.

**URL:** <https://community.unix.com/t/telnet-errors-coming-on-screen-while-using-snarf-command/333271>\
**Category:** Shell Programming and Scripting\
**Created:** [August 20, 2013, 5:43am UTC](https://community.unix.com/t/telnet-errors-coming-on-screen-while-using-snarf-command/333271 "2013-08-20T05:43:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raza\_Ali](https://community.unix.com/letter_avatar/raza_ali/32/6_449c533f586939b6e5f246632a46421f.png) [@Raza\_Ali](https://community.unix.com/u/Raza_Ali)\
**Post date:** [August 20, 2013, 5:43am UTC](https://community.unix.com/t/telnet-errors-coming-on-screen-while-using-snarf-command/333271/1 "2013-08-20T05:43:35Z")

</div>

Hi Team,

I am using one script, It is working fine, the problem is it gives unwanted telnet errors when I am using it.  
I just want to remove these unwanted errors/info from my screen.

```nohighlight
bash-3.00$ cat raza_site_temp
#!/usr/bin/bash
#rj835b
IFS="|"
REGEX="$*"
echo
snarf2 -c "show chassis status" `showHosts gsx |egrep "$REGEX"` > /dev/null > d1d1
echo
cat d1d1 |egrep -i "Node|Temp"|sed '/Node/{x;p;x;}'
echo
echo
echo "GSX Temperature > 30C"
echo " *********************"
echo
cat d1d1|egrep "Node|Temp"|awk '{if ($1~/Node:/) print $1,$2; else if ($1~/Temperature/) print $0}'|sed '$!N;s/\n/ /'|awk '{if (substr($4,1,2)>30) print $2,"----->", $4}'|awk '{printf "%-10s %s %s\n", $1,$2,$3}'
echo
bash-3.00$

```

Output of the script

```nohighlight
bash-3.00$ ./raza_site_temp hst

Enter GSX Login: Enter GSX Password: 
telnet: Unable to connect to remote host: Connection refused
Connection to 10.24.63.67 closed by foreign host.
Connection to 10.24.63.68 closed by foreign host.
telnet: Unable to connect to remote host: Connection refused
Connection to 10.24.63.70 closed by foreign host.
telnet: Unable to connect to remote host: Connection refused
Connection to 10.24.63.72 closed by foreign host.
telnet: Unable to connect to remote host: Connection refused
Connection to 10.24.63.74 closed by foreign host.
telnet: Unable to connect to remote host: Connection refused
Connection to 10.24.63.98 closed by foreign host.
telnet: Unable to connect to remote host: Connection refused

Node: hstg1so Date: 2013/08/20 09:35:31 GMT
Temperature: 25C

Node: hstg2so Date: 2013/08/20 09:35:39 GMT
Temperature: 26C

Node: hstg3so Date: 2013/08/20 09:35:48 GMT
Temperature: 24C

Node: hstg4so Date: 2013/08/20 09:35:55 GMT
Temperature: 25C

Node: hstg5so Date: 2013/08/20 09:36:03 GMT
Temperature: 25C

Node: hstg6so Date: 2013/08/20 09:36:11 GMT
Temperature: 25C

GSX Temperature > 30C
*********************

bash-3.00$

```

When I fire script it will ask for password, then it will fetch data from different node, error coming from redundant ports.  
I jus want these telnet and connection refused error does not appear on my screen.

Thanks  
Raza

---

<div class="post-metadata">

**Author:** ![Skrynesaver](https://community.unix.com/user_avatar/community.unix.com/skrynesaver/32/14143_2.png) [@Skrynesaver](https://community.unix.com/u/Skrynesaver)\
**Post date:** [August 20, 2013, 5:58am UTC](https://community.unix.com/t/telnet-errors-coming-on-screen-while-using-snarf-command/333271/2 "2013-08-20T05:58:37Z")

</div>

[s]You need to redirect STDERR to /dev/null as well to avoid these messages (unless inability to contact a host is of interest 😉 ), we can do this by redirecting stderr to stdout `2>&1` this is a very common idiom.

````nohighlight
snarf2 -c "show chassis status" `showHosts gsx |egrep "$REGEX"` > /dev/null > d1d1 2>&1
```[/s]

Duplicate thread... answered on the better formatted one.
````
