Copy link to clipboard
Copied
I've wrote a script that sends my current active project to aerender directly from a Script UI button. It works fine on my local machine like this…
myPanel.grp.group8.getPath.onClick = function() {
if(app.project.file !== null){
var path = app.project.file.fsName;
$.writeln(path);
}
var renderCommand = "/Applications/Adobe\\ After\\ Effects\\ 2020/aerender -project " + path;
system.callSystem(renderCommand);
}
However I would like the render to take place on a different machine which has access to the same files. The following Terminal command (from my machine) works (via ssh key) and the image sequence gets rendered ok…
ssh server@192.168.50.4 /Applications/Adobe\\ After\\ Effects\\ 2020/aerender -project /Volumes/Work/Jobs/test.aep
The problem is, if I try to add ssh into the AE script like this, it does not work…
myPanel.grp.group8.getPath.onClick = function() {
if(app.project.file !== null){
var path = app.project.file.fsName;
$.writeln(path);
}
var renderCommand = "ssh server@192.168.50.4 /Applications/Adobe\\ After\\ Effects\\ 2020/aerender -project " + path;
system.callSystem(renderCommand);
}
What am I doing wrong? What is the correct syntax to do this?
2 Correct answers
It might not be working because you're calling a string inside the system.callSystem() command on the last line.
renderAEP is a variable, and should be entered into the system.callSystem() like this:
system.callSystem(renderAEP) instead of system.callSystem('renderAEP');
Does that help?
YES YES YES YES YES YES.
I'm realising the reason it was accidently a string is because I had a string in there previously while doing some testing and forgot to delete the quotes! I have other buttons where there's a variable in that position, I just failed to notice the difference. Doh!
After correcting it, it still didn't work! Then I looked closely at the renderAEP variable itself and realized there's no space after the script name! So the command was being converted to…
sh ~/render.shVolumes
...
Copy link to clipboard
Copied
`renderCommand` variable is not possible to execute because it isn't valid.
First you have to ssh into the machine and of course go through some kind of authentication process. Once logged in, only then could you execute a command. Beyond that, though, operating systems are very particular about which processes can be executed by specific users remoting into a session.
You may be better off creating some kind of API running on the same machine that runs aerender. So, your ScriptUI could simply call that API remotely via something like http:// protocol. Doing so would effectively launch aerender with the correct parameters (i.e. project file, composition, etc.).
Hope this helps!
Copy link to clipboard
Copied
Thanks for your reply. I recieved not a single reply on Creative Cow, so I really appreciate your input.
What's your belief that the variable isn't valid? You seem to be suggesting that SSH wont work because SSH is a multi-step process (ie ssh address > enter password > run command at remote shell prompt). But the command is actually written as a single line that's executed in one go. I can literally paste that line into Terminal and boom… it logs in (via ssh key) and aerender launches on the remote machine.
ssh server@192.168.50.4 /Applications/Adobe\\ After\\ Effects\\ 2020/aerender -project /Volumes/Work/Jobs/test.aep
The problem is when I take that same (working) command and turn in into a Script UI button, it no longer works. However, like I said above, a local (none SSH) version of this command DOES work.
Your API suggestion is interesting, and I think I understand it in principle, but honestly I would have no idea where to start with that! I'm already pushing the limits of my coding knowledge with the Script UI stuff.
Copy link to clipboard
Copied
Hi Mark,
I didn't realize you could send a command in the ssh command to the remote. Nice to have learned something new.
When you run that command via system.callSystem() method from a ScriptUI it is likely being run from a separate environment that your user account — one different from when you start the terminal in a regular session. Are you able to run a simpler command rather than aerender? For example, can you do something like the following for printing text into a file? Maybe something like:
ssh server@192.168.50.4 "echo \"Testing execution on server\" >> ~/Desktop/test-output.txt"
Does a file get created on the machine?
Yes, API dev. is not necessarily the easiest to implement, but it does save alot of headaches in terms of security.
Copy link to clipboard
Copied
Good idea! Some progress has been made…
First of all, testing your suggestion locally DOES work…
var renderCommand = "echo \"Testing execution on server\" >> ~/Desktop/test-output.txt";
system.callSystem(renderCommand);
I modified your command to output the current user name to a file, and tried it via ssh. I had to backslash the quote before the id command and add a backslashed quote near the end. This now works (!!!), and confirms that the remote machine is executing commands as 'server'.
var renderCommand = "ssh server@192.168.50.4 \"id -un >> ~/Desktop/test-output.txt\"";
system.callSystem(renderCommand);
So I assume my issue with the SSH aerender command is lack of backlashed quotes. The original command didn't have quotes around the aerender path, where as echo and id commands above did. So now, this works and the project renders!…
SUCCESS!
However, the issue now is that AE pinwheels until the aerender is complete on the other machine haha. The same happens when I remove ssh from the command and aerender locally. I guess I need to find a way to let it run in the background or just send the command then return focus to AE?
Copy link to clipboard
Copied
Ok, so after some Googling, I've figured out how to run a command in the background by encasing it in an Apple Script…
system.callSystem('osascript -e \'tell\ application\ "Terminal"\ to\ do\ script\ [\"/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender\ -project /Volumes/Work/test.aep\"]\'');
That works if the aep location is hard wired into the command, but what I really need is to have it take the variable of the current aep project file instead.
After some tinkering around, I wrote this shell script that opens iTerm on my remote machine and starts 7 render instances (one iTerm window, but divided into 7 split windows - a great feature of iTerm)…
#!/bin/bash
ssh server@192.168.50.4 osascript <<EOF
tell application "iTerm"
activate
set newWindow to (create window with default profile)
select first window
# Split pane
tell current session of current window
split vertically with default profile
split vertically with default profile
split vertically with default profile
split vertically with default profile
split vertically with default profile
split vertically with default profile
end tell
# Exec commands
tell first session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell second session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell third session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell fourth session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell fifth session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell sixth session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell seventh session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
end tell
EOF
I can then run sh ~/render.sh "/Volumes/Work/Jobs/Test/test v2.aep" in my local terminal, and thanks to the $1 variable, that filepath is passed over and executed inside of the script, on the remote machine. The volume is accessible on both.
Copy link to clipboard
Copied
The closest I've got so far is this…
system.callSystem('osascript -e \'tell\ application\ "Terminal"\ to\ do\ script\ \"/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \" '+ pathToRender' \'');
This https://www.adminsys.ch/2013/07/31/add-bash-variables-osascript-e-command suggests that only single quotes are needed around osascript variables. Which does correctly color the variable blue in Visual Studio Code…
However it doesn't open the Script UI panel in AE. I get an error "Unable to execute script at line 83. Expected: )"
Also, I suspect that the command might need an ampersand before the variable (as is the case in the Automator Apple Script version in my previous reply). I tried the above command both with and without ampersand, but I still get the same AE error.
Copy link to clipboard
Copied
What I would really like to do though, is run the above script from inside of AE. My latest attempt to do this is as follows…
myPanel.grp.group4.sendRender.onClick = function() {
if(app.project.file !== null){
var pathToRender = app.project.file.fsName;
$.writeln(pathToRender);
}
var renderAEP = "sh ~/render.sh" + pathToRender;
system.callSystem('renderAEP');
It looks like it should work, but sadly it's doesn't. I have the sh ~/render.sh command and the variable pathToRender. I think that should be all I need, but I assume I'm missing something obvious. 😞
Copy link to clipboard
Copied
Ugh this is so annoying. This forum keeps losing my replies and edits.
I figured out most of the issue. To run in the background it needs to be inside of an AppleScript. I wrote this bash script (below), which I can execute like this… sh ~/render.sh "/Volumes/Work/Test/Test v2.aep". It creates 7 instances in 1 tidy window (split 7 times, thanks iTerm!).
#!/bin/bash
ssh server@192.168.50.4 osascript <<EOF
tell application "iTerm"
activate
set newWindow to (create window with default profile)
select first window
# Split pane
tell current session of current window
split vertically with default profile
split vertically with default profile
split vertically with default profile
split vertically with default profile
split vertically with default profile
split vertically with default profile
end tell
# Exec commands
tell first session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell second session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell third session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell fourth session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell fifth session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell sixth session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
delay 2
tell seventh session of current tab of current window
write text "/Applications/Adobe\\\\ After\\\\ Effects\\\\ 2020/aerender -project \"$1\" -sound ON"
end tell
end tell
EOF
What I'd really love though is for this script to be ran from inside of AE. I have the following in my jsx file, but it just does not work. I don't know why…
myPanel.grp.group4.sendRender.onClick = function() {
if(app.project.file !== null){
var pathToRender = app.project.file.fsName;
$.writeln(pathToRender);
}
var renderAEP = "sh ~/render.sh" + pathToRender;
system.callSystem('renderAEP');
Copy link to clipboard
Copied
It might not be working because you're calling a string inside the system.callSystem() command on the last line.
renderAEP is a variable, and should be entered into the system.callSystem() like this:
system.callSystem(renderAEP) instead of system.callSystem('renderAEP');
Does that help?
Copy link to clipboard
Copied
YES YES YES YES YES YES.
I'm realising the reason it was accidently a string is because I had a string in there previously while doing some testing and forgot to delete the quotes! I have other buttons where there's a variable in that position, I just failed to notice the difference. Doh!
After correcting it, it still didn't work! Then I looked closely at the renderAEP variable itself and realized there's no space after the script name! So the command was being converted to…
sh ~/render.shVolumes/Work/etc
I inserted a space after the script name, and BOOM it works…
var renderAEP = "sh ~/render.sh " + pathToRender;
system.callSystem(renderAEP);
Thank you SO much for sticking with me on this. I've spent days trying to figure this out. Have a great weekend!

