From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: jobdonecommand variables
   Date: Fri, 02 May 2008 16:00:58 -0400
Msg# 1730
View Complete Thread (2 articles) | All Threads
Last Next
Michael Oliver wrote:
> Hi everyone.  I'm writing a script to generate quicktime's automatically 
> when renders finish by using the jobdonecommand.  I have setup a few shake 
> scripts that will reference environment variables for the file-in, out, and 
> frame range and write out the appropriate quicktime.

	Actually you want to pass strings from the submit side of things
	to the render side of things as either arguments to the commands,
	or in a text file (if you have many arguments).

PASSING VALUES AS ARGUMENTS
---------------------------
	To pass around just simple arguments, you would do something like:

# SUBMIT
rush -submit << EOF
[..]
command        perl /path/to/your/render.pl -render $in{FileIn} $in{FileOut}
[..]
jobdonecommand perl /path/to/your/render.pl -jobdonecommand $in{FileIn} $in{FileOut}
EOF

	..and when render.pl runs, you parse $ARGV[0] to figure out
	if it was invoked with "-render" or "-jobdonecommand", and then
	parse out the rest of the arguments for file-in/file-out, eg:

### render.pl ###

# RENDER?
if ( $ARGV[0] eq "-render" )
{
    my $filein = $ARGV[1];
    my $fileout = $ARGV[2];
    [..render stuff here..]
    exit(0);
}

# JOB DONE COMMAND?
if ( $ARGV[0] eq "-jobdonecommand" )
{
    my $filein = $ARGV[1];
    my $fileout = $ARGV[2];
    [..jobdone stuff here..]
    exit(0);
}

	You can name the flags (-render, -jobdonecommand) whatever you want,
	just be consistent that you submit with the same flags you expect in
	your render script.

> What variables does jobdonecommand have access too?

	Any you make available, either as an argument (as shown above),
	or if there's a lot of them, you can shove them all into a file
	(eg. into the logdir), and load the file from the jobdonecommand.

	The only variables that are /always/ passed through are the
	environment variables RUSH sets, eg. RUSH_JOBID, RUSH_LOGFILE,
	etc. More info on those here:
	http://www.seriss.com/rush-current/rush/rush-environment-vars.html#Environment%20Variables

	Everything else is entirely local to the script, and have to be
	passed through either as args or in a file.


> For example can you reference $opt{sfrm} or $opt{ShakePath}from the original 
> render?

	Ya, just pass them as arguments at submit time; see above.

	Or, if you want access to ALL the variables, you can save them
	to a file using this technique..


PASSING VALUES THROUGH A FILE
-----------------------------
	To do the file approach, if you're using the example submit
	scripts, you'll notice on the submit side, all the variables
	are usually named $in{XXX} where XXX is the prompt name in the
	submit form without spaces, eg:

		$in{ScenePath}
		$in{LogDirectory}
		[etc..]

	..and on the submit side you can use the SaveInput() function
	to save that hash variable's entire contents to a file, eg:

		# SAVE THE CONTENTS OF %in HASH TO A FILE 'foo.txt'
		my $errmsg;
		if ( SaveInput(\%in, "/some/pathname/foo.txt", \$errmsg) < 0 )
		    { print "SaveInput() failed: $errmsg\n"; exit(1); }

	..and later, at render time, load that file back in with LoadInput(), eg:

		# LOAD THE CONTENTS OF %in HASH FROM A FILE 'foo.txt'
		my $errmsg;
		my %in;
		if ( LoadInput(\%in, "/some/pathname/foo.txt", \$errmsg) < 0 )
		    { print "LoadInput() failed: $errmsg\n"; exit(1); }

	..this will load the %in hash with everything that was originally
	in the variable at submit time.

	The "/some/pathname/foo.txt" should be on the file server, and should
	be a unique filename for your job. This is typically why one would
	use the 'log directory' for saving such a file. Either way, you can
	pass the filename as part of the 'command', eg:

rush -submit << EOF
[..]
command perl /path/to/your/render.pl -render /some/pathname/foo.txt
[..]
jobdonecommand perl /path/to/your/render.pl -jobdonecommand /some/pathname/foo.txt
[..]
EOF

	..and parse the pathname off the same was as if you were passing
	around the filein/fileout pathnames.

> If not how do you suggest passing the variables on to the jobdonecommand 
> perl script?
> I have been researching the message boards and running test scripts without 
> any luck.  I'm a little rusty on my perl programming so any help would be 
> greatly appreciated.  Thanks! 
> 
> 
> 
> 


-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

Last Next