Command A Commandline Based Tool

Mel Users,

I have the following question. A friend of mine made a DOS based exe for file conversions. I have to type within the DOS promt the name of the exe and the flags it needs. the flags differ a lot i.e. resolution, file size .....

Is there a way to directly do this from the script editor.

My solution now is to write the lines of commands to a batch file and run the batch file.

Maybe someone has a smarter solution?

Greetings, regards

Dawn3

read about the "system" command

Thanks Daniel

That was the first area to look but maybe i did not understand it correctly

this seems to be the way to do it....... in the example
system("start c:/windows/notepad.exe");

but for me it would look like this and its not working
system("start c:/windows/myprogram.exe -resolution -color -name");

But like i said it does not seem to work ;-(

maybe a little help

Start is a subshell command for windows applications it forks the execution. ome comd apps doent like it. secondly you usually need to point them to files and yu really ought to type \ instead of /

Some examples

CODE
menuItem -l ("Open SciTE") -command ("system(\"start \\"C:\\App\\Scintilla Text Editor\\SciTE.exe\\"\");") -echoCommand 1;

menuItem -l ("Open Scripts Folder") -command ("system(\"start explorer \\"C:\\Project\\scripts\\"\");") -echoCommand 1;

menuItem -l ("Open Project") -command ("system(\"load \\"C:\\Project\\usr.sln\\"\");") -echoCommand 1;

system("del \"" + toNativePath($filePath) +  "\";"); // delete file

system("start \"C:\App\Nero 7\Nero WaveEditor\waveedit.exe\" \"" + $fileName + "\"");

string $file = getAttr ($recorder + ".lastSavedFile");
system("load \"" + $file + "\"");

Thanks for all the helpfull posts but you seem to have to do with a dummy :wink:

it is clear to me that a program can be launched from maya but i still don't understand how to ad flags to the command utillity.

My normal workflow:
-open cmd.exe
-browse to utility (example d:\tmp)
-type the command (myutil.exe -color -resolution)

the start to do this from maya would probably be
system("start \"C:\WINDOWS\system32\cmd.exe\"");

but i don't understand the starting of the custom exe with its flags??

Help for a dummy

system is by itself the cmd.exe, so you won't call the cmd.exe.

system load filename: opens the filename with the default application (like when you double click on a non exe file. eg. *.doc). You don't want that.

system pathToExe.exe: starts the executable and blocks maya until the pathToExe.exe application closes. You may want that.
system start pathToExe.exe: starts the executable without blocking. This may be what you want.

take a look at this one:
system("start \"C:\App\Nero 7\Nero WaveEditor\waveedit.exe\" \"" + $fileName + "\"");

this is the same as
1) launching cmd.exe
2) typing in "C:\App\Nero 7\Nero WaveEditor\waveedit.exe" "c:\filename.wav"

so you want to do

system("start \"C:\directory\myutil.exe\" -color -resolution");

In the nero example above there is this part \"" + $fileName + "\" this is to end up wiht a string "c:\path to file\file.wav" in quotes because else the command would fail because the waveedit exe would think that only c:\path is the filename. then the wort to would be erroneously passed in as the second argument and file\file.wav as the third argument.

Daniel,

Thanks very much, now i understand it correctly and it works.

very nice of you to do the expanation.

Regards,

Dawn3

QUOTE(Daniel_Faus @ 08/09/07, 11:29 PM) [snapback]271276[/snapback]
take a look at this one:
system("start \"C:\App\Nero 7\Nero WaveEditor\waveedit.exe\" \"" + $fileName + "\"");

this is the same as
1) launching cmd.exe
2) typing in "C:\App\Nero 7\Nero WaveEditor\waveedit.exe" "c:\filename.wav"

well actually not, system itself is like launching cmd, but if you launched cmd from cmd you end up with one cmd window And the program, start just forks the execution environment (otherwise maya would wait for the program to terminate to continue the script) without a extra cmd session.

you're right, I agree. So instead of 1) launching cmd.exe I should have writen 1) Open Start/Run...

oke guys...............

A lot of thanks it is working :wink:

I dont have to write to batch files anymore but i have another question ;-0 since almost everything is working now.

The commandline tool spits out text for every phase off converting i.e. "first phase finished" "10%" "20%"

is it possible to get this back within the sript editor??

thanks........