|
Last change
on this file since 13395 was 13395, checked in by Mathieu Morlighem, 13 years ago |
|
merged trunk-jpl and trunk for revision 13393
|
|
File size:
969 bytes
|
| Rev | Line | |
|---|
| [3150] | 1 | function 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
|
|---|
| 8 | hostname=oshostname();
|
|---|
| 9 |
|
|---|
| 10 | %if same as host, just run the command.
|
|---|
| 11 | if strcmpi(host,hostname),
|
|---|
| 12 | system(command);
|
|---|
| 13 | else
|
|---|
| [13170] | 14 | if ispc(),
|
|---|
| [1582] | 15 | %use the putty project plink.exe: it should be in the path.
|
|---|
| 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
|
|---|
| 37 | end
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.