View Full Version : system() vs Windows Commands?
06 June 2007, 11:18 PM
Something really weird is happening with how system() MEL command is executing windows shell commands.
Help reference states that to load an application in a foreground, all you need to do is not to use start or shell (which doesn't seem to exist in my XP), like that:
system("C:/aw/Maya/bin/fcheck.exe " + $filename);
But this won't work, at all. No matter what application you supply, even the notepad won't launch.
Well, if that isn't really working, I turned to start command. This:
system("start C:/aw/Maya/bin/fcheck.exe " + $filename);
will work, but the problem with it is that it will pop up an ugly black shell screen, together with fcheck, notepad, or any other application.
So an intuitive thing would be to add the /B (omit shell window) flag to start command, right?
system("start /B C:/aw/Maya/bin/fcheck.exe " + $filename);
The problem is in that this code won't work, at all. Not even the simple version:
system("start /B notepad");
The same is true for any flags /MIN, /W etc.
Looks like system() MEL command is filtering the arguments for start command? Or it is just totally broken on Windows. Because it is working perfectly on Linux and OSX.:shrug:
I would be very glad to know if you had any experience with this, especially those in Maya dev team (would appreciate your input here Tim).
Thanks for any help,
06 June 2007, 04:27 AM
This works fine for me.
Is there any chance there is a space in the path or filename. Command line won't allow this, so you have to enclose the filename in quotes.
system("C:/aw/Maya/bin/fcheck.exe \"" + $filename + "\"");
Also, if your Maya bin directory is in your environment path variable (which Maya does by default) you don't need the path to fcheck.exe.
system("fcheck.exe \"" + $filename + "\"");
Hope that helps,
06 June 2007, 07:55 AM
Thanks for your reply. Well, fcheck is just what they use as an example in Maya command reference. This could be any application you'd want to run with supplying the full path.
And yep, I am considering the spaces in paths, so they are enclosed in quotes. As you might notice the start command on my paths actually works, but as soon as I'm trying to parse some flags, it won't.
Just tried something, this:
system("C:/path/path/myApplication.exe " + $filename);
actually works on my 64 bit XP setup, but not at all on 32 :shrug: But start command still refuses to work with any flags recieved.
So when you run this:
system("start /B notepad");
The notepad pops up? This doesn't work on neither of my 32 or 64 bit XP's.
06 June 2007, 09:33 AM
Hey henryKorol! Nice to read from you :]
I use another shell command: load
Here Maya freezes as long as the app is running if I don't use start or load (wich of course is necessary for some purposes like cvs.exe or attrib.exe...)
I don't know what "load" exactly does contrary to start ( or shell (I have no black dos shell here if I use this btw)) But maybe you can try it as well.
oh pardon: forgot example:system("load C:/windows/NOTEPAD.EXE");
06 June 2007, 09:03 AM
Hey, thanks! :) load will just try to open the specified file with an appropriate application. So it isn't really a way of running other programs. Although they'll run, you can't parse any parameters to them (which you'll need badly with command line tools).
start on the other hand is used to run other programs, so it can parse arguments to them. The problem is that start is by default running the programs in the background (another thread). And many times you would like to wait for the system command to be finished before going on with your script.
So what I tried is to parse the parameter, "\W" which should force the start to wait while parsed program finished executing. This works from the cmd, but it doesn't from within Maya, via the system() command. I hope some could shed some light on this :)
Another interesting thing, is that running applications without start or load won't work on my old XP setup, at all. They work perfectly on new (64 bit, but shouldn't make difference) install. Maya itself runs well on both setups, it's just that system command is having trouble here. :shrug:
Perhaps somethings is just wrong with my old XP setup, could you check and confirm if simple examples like:
work for you?
Thanks a lot before hand,
06 June 2007, 10:12 PM
Works for me. I'm using Maya 8.5 with Windows 2000.
06 June 2007, 08:33 AM
Ah ok. thx for explaining load!
Yea, if you want the return-stuff of the app you start via system() you have to pass on load or start or whatever.
We use that all day. A lot of our pipeline relays on system("app.exe")-calls. (eg complete CVS-linkup in Maya)
06 June 2007, 07:53 PM
Thanks a bunch guys :) So I'll probably go with a working on most systems "system("cmd.exe");" version. And will use my buggy XP setup to test the error handler :D
06 June 2007, 07:53 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.