Hi John,
On Wed, Feb 13, 2013 at 07:44:56AM -0600, inode0 wrote:
On Wed, Feb 13, 2013 at 3:12 AM, Suvayu Ali
<fatkasuvayu+linux(a)gmail.com> wrote:
> 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.
I know about redirection, but was not aware that I could also open
sockets! Thanks a lot for the nice explanation, I'll read up more.
I think I'll end up using this solution as it seems the most portable.
Cheers,
:)
--
Suvayu
Open source is the future. It sets us free.