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

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

merged trunk-jpl and trunk for revision 26742

File size: 976 bytes
RevLine 
[3150]1function issmssh(host,login,port,command)
[2538]2%ISSMSSH - wrapper for OS independent ssh command.
[1582]3%
[2538]4% usage:
5% issmssh(host,command)
[1582]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
[26744]14 if ispc & ~ismingw,
[1582]15 %use the putty project plink.exe: it should be in the path.
[13975]16
[12155]17 %get ISSM_DIR variable
18 [status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
[1582]19 if status,
[12743]20 error('issmssh error message: could not find ISSM_DIR_WIN environment variable');
[1582]21 end
[12155]22 ISSM_DIR=ISSM_DIR(2:end-2);
[1582]23
24 username=input('Username: (quoted string) ');
[9369]25 key=input('Key: (quoted string) ');
[1582]26
[12155]27 system([ISSM_DIR '/externalpackages/ssh/plink.exe -ssh -l "' username '" -pw "' key '" ' host ' "' command '"']);
[1582]28
29 else
30 %just use standard unix ssh
[3150]31 if port,
32 eval(['!ssh -l ' login ' -p ' num2str(port) ' localhost "' command '"']);
33 else
34 eval(['!ssh -l ' login ' ' host ' "' command '"']);
35 end
[1582]36 end
37end
Note: See TracBrowser for help on using the repository browser.