On 02/13/2013 09:44 PM, inode0 wrote: > On Wed, Feb 13, 2013 at 3:12 AM, Suvayu Ali <fatkasuvayu+linux@xxxxxxxxx> wrote: >> Hi John, >> >> On Tue, Feb 12, 2013 at 08:37:27PM -0600, inode0 wrote: >>> Something like this perhaps. >>> >>> $ 2>/dev/null >/dev/tcp/imap.gmail.com/993 && sync-my-email.sh >> This works, but I don't think I understand it. Could you please >> explain? > Bash provides built-in ways to manipulate sockets directly. You can > read the REDIRECTION section of the bash man page to get the basics. > Commonly these are used in conjunction with exec to open a socket, > read and/or write data to the socket, then close the socket. > > In the simple case here we just have bash attempt to open a tcp socket > to imap.gmail.com on port 993 and return whether it was successful or > not. The advantage of doing this is that we don't need to rely on any > external program to perform such a simple test. > One thing of interest to note but which may not affect what the OP is doing.... If the port being tested is listed as "filtered" by nmap [egreshko@meimei ~]$ nmap -Pn -p143 imap.gmail.com Starting Nmap 6.01 ( http://nmap.org ) at 2013-02-13 21:53 CST Nmap scan report for imap.gmail.com (173.194.64.108) Host is up. Other addresses for imap.gmail.com (not scanned): 173.194.64.109 rDNS record for 173.194.64.108: oa-in-f108.1e100.net PORT STATE SERVICE 143/tcp filtered imap the command 2>/dev/null >/dev/tcp/imap.gmail.com/143 && echo "yes" will hang for quite some time.... -- Don't be bullied by the judgmental grammar and spelling police. -- users mailing list users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org