Mercurial > hg > ltpda
comparison m-toolbox/html_help/help/runcmd.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function runcmd(varargin) | |
2 | |
3 % This will run a shell command from within MATLAB using the given | |
4 % arguments. | |
5 % | |
6 % usage: runcmd(varargin) | |
7 % | |
8 % varargin - a series of strings to be concatenated together. | |
9 % | |
10 % | |
11 % e.g. >> runcmd('ls', '-l', dir); | |
12 % | |
13 % M Hewitson 16-07-04 | |
14 % | |
15 % $Id: runcmd.m,v 1.2 2007/10/24 10:59:50 ingo Exp $ | |
16 % | |
17 | |
18 | |
19 fid = fopen('tmpcmd', 'w+'); | |
20 | |
21 fprintf(fid, '#!/bin/bash\n'); | |
22 fprintf(fid, 'export PATH=$PATH:${HOME}/bin\n'); | |
23 for j=1:nargin | |
24 fprintf(fid, '%s ', varargin{j}); | |
25 end | |
26 fprintf(fid, '\n'); | |
27 | |
28 fclose(fid); | |
29 | |
30 !chmod +x tmpcmd | |
31 !./tmpcmd | |
32 %!rm tmpcmd | |
33 | |
34 |