nc -zv 127.0.0.1 3306 < /dev/null; echo $?
if [ $? == "0" ]; then
echo "Telnet accepting connections"
else
echo "Telnet connections not possible"
fibu scripti ./kontrol.sh - sh kontrol.sh
başına bin/bash - bin/sh ekledim hepsinde denedim hepsinde ise aldığım hata
Syntax error: "fi" unexpected (expecting "then")
bu
başına hiçbir şey eklemeden aşağıdaki gibi çalışması lazım.
nc -z 127.0.0.1 3306 < /dev/null
if [ $? == "0" ]; then
echo "Telnet accepting connections"
else
echo "Telnet connections not possible"
fi
Alıntı
[root@www ~]# sh kon.sh
Connection to 127.0.0.1 3306 port [tcp/mysql] succeeded!
Telnet accepting connections
veya tek satır çıktı istiyorsanız
nc -z 127.0.0.1 3306 1>/dev/null 2>&1; result=$?;
if [ $result -eq 0 ]; then
echo "Telnet accepting connections"
else
echo "Telnet connections not possible"
fi