Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

get_ip.m 717 B

12345678910111213141516171819202122232425262728293031323334
  1. function ip = get_ip()
  2. %%
  3. if ispc
  4. [r,p]=system('ipconfig /all')
  5. elseif ismac
  6. [r,p] = system('ifconfig');
  7. ind = strfind(p,'inet ');
  8. indshift = 5;
  9. else
  10. [r,p] = system('ip route get 1 | grep -oP "src \K\S+"');
  11. ip = strtrim(p);
  12. return;
  13. end
  14. %%
  15. ipind = 1;
  16. found = false;
  17. for ix = 1:numel(ind)
  18. thisip = strtrim(strtok(p(ind(ix)+indshift:ind(ix)+indshift+15),' '));
  19. if ~strcmp(thisip, {'127.0.0.1','127.0.1.1'})
  20. IP{ipind} = thisip;
  21. found = true;
  22. end
  23. end
  24. if found
  25. if numel(IP)>1
  26. fprintf(2,'GOt multiple IPs returning first');
  27. end
  28. ip = IP{1};
  29. else
  30. fprintf(2,'In db.get_ip no valid IP addresses found. Maybe this OS has a different format for ifconfig.\n')
  31. end