| Line | |
|---|
| 1 | function hostname=oshostname()
|
|---|
| 2 | %OSHOSTNAME figure out hostname, irrespective of os type
|
|---|
| 3 | %
|
|---|
| 4 | % usage: hostname=oshostname();
|
|---|
| 5 | %
|
|---|
| 6 | %
|
|---|
| 7 |
|
|---|
| 8 | if ispc,
|
|---|
| 9 | [status,hostname]=system('hostname');hostname=hostname(1:end-1);
|
|---|
| 10 |
|
|---|
| 11 | if status,
|
|---|
| 12 | error('oshostname error message: could not run hostname command on windows os');
|
|---|
| 13 | end
|
|---|
| 14 |
|
|---|
| 15 | else
|
|---|
| 16 | [status,hostname]=system(['hostname -s | sed ''s/-//g''']);
|
|---|
| 17 | if status,
|
|---|
| 18 | error('oshostname error message: could not run hostname command on *nix os');
|
|---|
| 19 | end
|
|---|
| 20 | hostname=hostname(1:end-1);
|
|---|
| 21 | hostname=ddewhite(hostname);
|
|---|
| 22 | end
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.