I've been making a mel tool that will write out a batch render shell script for me based on the scenes I give it. My only real issue these days is that I have to first ceate a text file with ".sh" extension and set the permisions, then I can get maya to edit that file.
If I use this code below I can get maya to create the text file for me, but its permisions are still not set correctly. I have to then take that file and run chmod 755 on it in the terminal (I'm on a mac) before i can run it.
$FileName = ("/Users/myUser/Desktop/File.sh");
$fileId = fopen $FileName "w";
fprint $fileId "A bunch of text\n";
fclose $fileId;
The maya docs on fopen are pretty limited and I 've been searching the web in vain, but does anyone know if its possible to set the permissions on a file when fopen creates it so that I can alleviate that whole extra step of editing the permisions after the fact?
have to then take that file and run chmod 755 on it in the terminal
use the system command
but does anyone know if its possible to set the permissions on a file when fopen creates
no dont think so, use a sytem command to chmod. Only commads that make sense across sytems make really sense. So if it has no menaing in windows but does have maning in linux and OSX, then implement the separate changes in the separate commands. Now since the stuff your doing is not sytem independent anyway doing one extra system call is not a big deal.
I have to first ceate a text file with ".sh" extension
Actually it doesnt really matter what the extension is. Thats whty you need to chmod things.