Commit bb441b90 authored by Jesse Heckman's avatar Jesse Heckman
Browse files

back up functions added

parent 76ba8915
function pb_makeglobal(varargin)
% PB_MAKEGLOBAL()
% PB_MAKEGLOBAL(varargin)
%
% PB_MAKEGLOBAL() ...
% PB_MAKEGLOBAL(varargin) ...
%
% See also ...
% See also PB_MOUNTSERVER, PB_MAKELOCAL
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
......
function pb_makelocal()
% PB_MAKELOCAL()
function pb_makelocal(varargin)
% PB_MAKELOCAL(varargin)
%
% PB_MAKELOCAL() ...
% PB_MAKELOCAL(varargin) copies dat from server to local computer.
%
% See also ...
% See also PB_MOUNTSERVER, PB_MAKEGLOBAL
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
user = pb_keyval('user',varargin,'JJH');
local = pb_keyval('destination',varargin,[pb_datapath filesep user]);
srv = pb_keyval('server',varargin,'mbaudit5');
srv = ['~/Volumes/' srv];
if ~exist(srv,'dir')
disp('Server cannot be found. Please first mount server (pb_mountserver).');
return
end
cdir = pb_getdir('dir',srv,'title','Select Data..');
dest = [local filesep cdir(find(cdir==filesep, 1,'last')+1:end)];
if exist(dest); dest = [dest ' (1)']; end
cnt = 0;
while exist(dest)
cnt = cnt+1;
dest = [dest(1:end-2) num2str(cnt) ')'];
end
copyfile(cdir, dest);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......
function pb_mountserver(varargin)
% PB_MOUNTSERVER()
% PB_MOUNTSERVER(varargin)
%
% PB_MOUNTSERVER() ...
% PB_MOUNTSERVER(varargin) mounts server for pulling or storing data. TO
% DO: Fix for different OS's.
%
% See also ...
% See also pb_makelocal
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
srv = pb_keyval('server',varargin,'mbaudit5');
[s,c] = system(['mount -t smbfs //' getcredentials(srv) '@' srv '-srv.science.ru.nl/' srv ' ~/sharename/']);
srv = pb_keyval('server',varargin,'mbaudit5');
cin = ['mount -t smbfs //' getcredentials(srv) '@' srv '-srv.science.ru.nl/' srv ' ~/sharename/'];
[s,cout] = system(cin);
if s > 0 && s ~= 64; disp(cout); end
if s == 64; system('umount ~/sharename/'); end
end
function auth = getcredentials(srv)
% obtains authentication credentials for server
doi = [userpath '.credentials'];
if ~isfolder(doi); mkdir(doi); end
......@@ -22,23 +26,28 @@ function auth = getcredentials(srv)
if ~exist(fn,'file')
fid = fopen(fn,'wt');
[str1,str2] = dlg(srv);
fprintf(fid, '%s:%s', str1, str2);
fprintf(fid,'%s:%s',str1,str2);
fclose(fid);
end
fid = fopen(fn);
auth = textscan(fid,'%s'); auth = auth{1,1}; auth = auth{1,1};
fid = fopen(fn);
auth = textscan(fid,'%s');
auth = auth{1,1};
auth = auth{1,1};
fclose(fid);
end
function [str1,str2] = dlg(srv)
prompt = {'Enter your username:','Enter password:'};
title = ['Connecting to ' srv];
definput = {'jheckman','s'};
dims = [1 75];
% dialog box
prompt = {'Enter your username:','Enter password:'};
title = ['Connecting to ' srv];
definput = {'jheckman','password'};
dims = [1 75];
answer = inputdlg(prompt,title,dims,definput);
str1 = answer{1}; str2 = answer{2};
answer = inputdlg(prompt,title,dims,definput);
str1 = answer{1};
str2 = answer{2};
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment