I'm not able to use URLFetch in my $UserBaseDirectory/Kernel/Init.m as it always returns ImportString[Null, Text, CharacterEncoding -> "ISO8859-1"].
Here is my test code, which works in a Notebook, but runs forever in the init file:
ip = $Failed;
While[ip == $Failed,
ip = Quiet@Check[URLFetch@"http://tyilo.com/ip/", $Failed]
];
MessageDialog[ip];
The reason I would like to use URLFetch in my init script is that I have distributed it to a couple of friends and I would like to make it automatically update.
Everything except the URLFetch part of the auto-update script works, so it would be nice to be able to finish this feature.
If you could make it run asynchronously after Mathematica has fully started up, that would be fine too.
$Epiloginstead. (I haven't tried it and it should be noted that it's invoked when returning from aDialogas well, which may not be a good thing in this case.) Be careful about using things likeMessageDialog, they're not command line friendly. – Szabolcs Sep 24 '13 at 00:38Needs["JLink`"]; JLink`InstallJava[]does work in init.m, but it doesn't fix URLFetch. – Szabolcs Sep 24 '13 at 00:40init.m. Back then, the check for the OS likeIf[StringMatchQ[$SystemID,"Linux-*"],..did not work. I thought we (I mean literaly, you and me) had spoken about it. – halirutan Sep 24 '13 at 00:57StringMatchQuses some java stuff for the regex matching. – halirutan Sep 24 '13 at 00:58$Epilogdoesn't seem to work either. – Tyilo Sep 24 '13 at 05:35