AE ENHANCERS

Expressions/Scripts/Presets
It is currently Thu Dec 18, 2014 5:30 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Render and shutdown
PostPosted: Thu Nov 25, 2004 12:36 am 
Offline

Joined: Sat Jun 12, 2004 6:40 pm
Posts: 57
As per discussions on the AE Listserv I have tossed together a basic render and shutdown script.

The script will render all queued objects in the render queue then it will shutdown.

This has not been tested on mac to please let me know how well it works

http://www.leapfrog-productions.com/Scr ... utdown.jsx


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 25, 2004 3:11 am 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
Unfortunately in the current state it doesen't work on a mac. The error message says : "There is no defautl application specified to open the document "shutoff.bat"

So it seems that the part of your script that doesen't work is the creation of the sh file. I saw the bat file being created, even though I'm on a mac.

I looked into Applescript, and you could in fact have a simple applescript attached to your script called "Shutdown" and that would simply say something like

tell application "Finder" to shut down

But the Shell script is probably even better.

Why would you think it doesen't recognize the mac?

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 25, 2004 2:22 pm 
hmm so its locked to seeing it as a bat file. Does just using this part:

var exe_shutoff = new File("shutoff.sh");
exe_shutoff.open("w");
exe_shutoff.writeln("#!/bin/sh");
exe_shutoff.writeln("shutdown -h now");
exe_shutoff.writeln("rm shutoff.sh");
exe_shutoff.close();
exe_shutoff.execute();

in a script work? or does it give the bat file message as well?


Top
  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 3:29 am 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
The error I get when I get rid of the PC part of the script is :

"After Effects error : Can't import file "shutoff.sh":unsupported filetype or extension. (0-1)"

If I look at the desktop (place where the file was rendered), the .sh file was created. However if I double click on it to open it, it will invoke After Effects. This is probably because AE created the file, but I guess it is not the expected behavior, as the terminal sounds more like the correct app to open the file.

Why would AE want to import the script?

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 5:05 pm 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 698
Location: London, UK
The reason the script always writes a .bat file regardless of mac or pc, is the line towards the end of the script:
if (isMac = "false"){
which should be:
if (isMac == "false"){
i.e. the script is saying "make isMac equal false", when it should say "is isMac equal to false".

Also, while the line var isMac = "true"; assigns the string "true" to the variable, a more 'proper' way would be to write var isMac = true; which would assign the boolean true (i.e a variable that can only be true or false). It's a small point, but it means you can do things like:
var isThisTrue = true;
if (isThisTrue) {
i.e. if (true)
or
if (!(isThisTrue)) { i.e if (not (true))
What comes after the 'if' statement only proceeds if the argument between the brackets is true, and because a boolean variable is inherently either true or false, you don't need to write if (isThisTrue == true). Like I said, it's a small point.

As for why it still doesn't work even when the script is corrected, it appears to be trying to open the .sh file into AE, because that is the creator of the file. It doesn't seem that a .sh file is even a recognised extension, in fact I don't think you can create a file that will launch into the Terminal app (if this is what you're expecting it to open in). Unfortunately I don't have any experience in this whole area so I haven't been able to get any further in my investigations.

Paul T


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 10:43 am 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
Also, as I recently learned, you can't run a shutdown script without being logged in as root. I suppose you could use sudo, but you would probably need to identify, so it kind of beats the purpose of the script.

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 01, 2005 4:31 pm 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 698
Location: London, UK
Well it looks like I may have got Render & Shutdown working on the Mac, here's a new version of the script:
http://www.paul.tuersley.btinternet.co.uk/scripts/Render_n_Shutdown.zip

Instead of trying to get the script to write and launch an applescript (which may not be possible), I just got it to launch a shutdown applescript that I've included in the same folder as the .jsx script. Also, I added a line to the .jsx that closes the project without saving before it launches the shutdown script.

Paul T


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 1:46 am 
Offline

Joined: Sat Jun 12, 2004 6:40 pm
Posts: 57
ah very nice :)

I would assume then that anyone who wanted to setup things like the Gspot etc scripts for example on mac with mac applications would be able to use the same idea.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 12, 2005 9:23 am 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
Paul, I noticed a catch with this script.

Yesterday I had setup a sort fo "master" render project for a bunch of other projects. I imported all the projects that had queued items and set the master render project to run (with render_and_shutdown).
One or more outputs modules had already been rendered in the "child" projects, and so I got the dialog box asking me if I wanted to overwrite previous modules.
As I said no, I think AE assumed it had done its job, and proceeded to shutdown and run the Applescript. This made me wait for the computer to shutdown, re-start, clean up my master render window, and relaunch the script.

Would there be a way for the script to understand the render hadn't actually taken place?

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 12, 2005 4:35 pm 
Offline

Joined: Sat Jun 12, 2004 6:40 pm
Posts: 57
Hmm I would think you would just add into the check where it looks at RQitemStatus.QUEUED and add a test to see if any modules are marked as DONE then pull them out of the que list variable.


Top
 Profile  
 
 Post subject: Re: Render & shut down using pure js
PostPosted: Sun Dec 13, 2009 1:55 am 
Paul Tuersley wrote:
Instead of trying to get the script to write and launch an applescript (which may not be possible), I just got it to launch a shutdown applescript ...


Hey Paul.
In case you ever want to get this to work without having to use the external applescript app, you can do it this way:

Code:
system.callSystem('osascript -e \'   tell application "Finder" to shut down   \'');


Top
  
 
 Post subject: Re: Render and shutdown
PostPosted: Sun Dec 13, 2009 5:43 pm 
Incidentally, for the Mac-heads out there:
There is a particular advantage in using the "inline" method I presented above.
The only caveat to this is that I do not have Snow Leopard yet, so I have no idea if any of this functionality is broken in OS 10.6+.
If you run the osascript command without the "-e" option, specifying a script file, you cannot have user interaction (using, for example, AppleScript's "display dialog" command). But using the "-e" option allows this sort of thing, and this includes running this command using callSystem in an AE jsx.
So, you can do the following, which has two osascript calls in one callSystem line (go ahead and try it -- and if you have Snow Leopard, I would much appreciate feedback on whether or not this works in the latest OS:

Code:
system.callSystem('osascript -e \'   activate application "Finder"\' ; osascript -e \'   tell application "Finder" to display dialog "Is this amazing?" buttons {"Slightly"} default button 1   \'');


Apologies for the long line. Spaces are added for readability. Of course, each callSystem/osascript command can be written in separate lines:

system.callSystem('osascript ... (first)
system.callSystem('osascript ... (second)

I just wanted to show what you could do with one line if you wanted.

This essentially makes the jsx/applescript possibilities limitless, although wrangling single quotes, double quotes and escaped quotes can be annoying.

-CG


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group