For Programmers: Free Programming Magazines  


Home > Archive > Matlab > April 2005 > Running DOS commands?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Running DOS commands?
David Lee

2005-04-27, 9:01 pm

Hi,

I am curious how to run commands in DOS via MATLAB.
I am aware of the ! operator, however, I am running DOS commands that
require further input. I would like to script an m-file that runs the
command and further inputs within it.

This is just an example:
!command %break to command prompt and waits for input
!exit %exit command prompt and go back to matlab

However, what happens after running "!command", the user has to
manually input "exit" to exit. I would like for the second line to be
implemented within the first command, such that in this example,
Matlab will break to command prompt and instantly return from it when
the m-file is run.

Thanks,
David
us

2005-04-27, 9:01 pm

David Lee:
<SNIP wants to run interactive dos-commands from ML...

i'd probably create a dos-batch file
just a thought
us
David Lee

2005-04-27, 9:01 pm

us wrote:
>
>
> David Lee:
> <SNIP wants to run interactive dos-commands from ML...
>
> i'd probably create a dos-batch file
> just a thought
> us


Thanks, I tried that, but found the same problem...

For instance C:\temp.bat runs the following:

@echo off
pause
5

However, pause is still waiting for user to press any key. 5 is not
considered an operation on pause.
Kristin Thomas

2005-04-27, 9:01 pm

Hi David,

You should be able to use ! to run interactive dos commands in MATLAB. The
shell will exit on its own when the script is done running.

Try this as an example from the Command Window:
!touch foo
!rm -i foo

Hope this helps,
Kristin

---------------------------------------------------------
Kristin Thomas
Software Engineer
The MathWorks, Inc.
kthomas@mathworks.com
---------------------------------------------------------

David Lee wrote:
> Hi,
>
> I am curious how to run commands in DOS via MATLAB.
> I am aware of the ! operator, however, I am running DOS commands that
> require further input. I would like to script an m-file that runs the
> command and further inputs within it.
>
> This is just an example:
> !command %break to command prompt and waits for input
> !exit %exit command prompt and go back to matlab
>
> However, what happens after running "!command", the user has to
> manually input "exit" to exit. I would like for the second line to be
> implemented within the first command, such that in this example,
> Matlab will break to command prompt and instantly return from it when
> the m-file is run.
>
> Thanks,
> David

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com