source: issm/trunk/src/m/os/issmssh.m@ 26744

Last change on this file since 26744 was 26744, checked in by Mathieu Morlighem, 3 years ago

merged trunk-jpl and trunk for revision 26742

File size: 976 bytes
Line 
1function issmssh(host,login,port,command)
2%ISSMSSH - wrapper for OS independent ssh command.
3%
4% usage:
5% issmssh(host,command)
6
7%first get hostname
8hostname=oshostname();
9
10%if same as host, just run the command.
11if strcmpi(host,hostname),
12 system(command);
13else
14 if ispc & ~ismingw,
15 %use the putty project plink.exe: it should be in the path.
16
17 %get ISSM_DIR variable
18 [status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
19 if status,
20 error('issmssh error message: could not find ISSM_DIR_WIN environment variable');
21 end
22 ISSM_DIR=ISSM_DIR(2:end-2);
23
24 username=input('Username: (quoted string) ');
25 key=input('Key: (quoted string) ');
26
27 system([ISSM_DIR '/externalpackages/ssh/plink.exe -ssh -l "' username '" -pw "' key '" ' host ' "' command '"']);
28
29 else
30 %just use standard unix ssh
31 if port,
32 eval(['!ssh -l ' login ' -p ' num2str(port) ' localhost "' command '"']);
33 else
34 eval(['!ssh -l ' login ' ' host ' "' command '"']);
35 end
36 end
37end
Note: See TracBrowser for help on using the repository browser.