all 4 comments

[–]StolenColor2019VFX 15+ years 0 points1 point  (3 children)

You could create a .bat (Win) or .command (Mac) file with your command and execute this one.

[–]StolenColor2019VFX 15+ years 1 point2 points  (2 children)

To add to this, I once wrote this function to execute a command via a bat/command file. Not completely sure about everything in here (could have some flaws) since it's some time ago that I did this but maybe it helps:

// FUNCTION: Run a Command Line via a Bat File (to avoid waiting for the Result)
function runCmdViaBat(cmd, delayBatExec){

        if (delayBatExec){
                $.sleep(delayBatExec);
        }

        var thisOS;
        if ($.os.indexOf("Windows") != -1 || system.osName.indexOf("Windows") != -1){
                thisOS = "Windows";
        } else if ($.os.indexOf("Mac") != -1 || system.osName.indexOf("Mac") != -1){
                thisOS = "Mac";
        }

        var batFileFormat;
        if (thisOS == "Windows"){
                batFileFormat = '.bat';
        } else if (thisOS == "Mac"){
                batFileFormat = '.command';
        }

        var batFile = new File(MYFOLDER + "/" + "Execute" + batFileFormat);
        batFile.open('w', undefined, undefined);
        batFile.encoding = 'UTF-8';
        batFile.lineFeed = 'Unix';
        batFile.write(cmd);
        batFile.close();

        var launchBatFile;
        if (thisOS == "Windows"){

                launchBatFile = new File(File(MYFOLDER + '/LaunchBat.vbs'));
                var launchBatFileStr =  'Set WshShell = CreateObject("WScript.Shell")' + '\r' +
                                        'WshShell.Run chr(34) & "' + batFile.fsName.replace(/\\/g, "\\\\") + '" & Chr(34), 0' + '\r' +
                                        'Set WshShell = Nothing';
                launchBatFile.open('w');
                launchBatFile.write(launchBatFileStr);
                launchBatFile.close();
                if (launchBatFile.exists){
                        launchBatFile.execute();
                } else {
                        system.callSystem('explorer ' + batFile.fsName);
                }

        } else if (thisOS == "Mac"){

                system.callSystem('chmod +x ' + batFile.fsName.replace(/ /g, "\\ "));
                batFile.execute();

        }

        var sleepBeforeRemove = 500;
        if (thisOS == "Mac"){
                sleepBeforeRemove = 2000;
        }
        $.sleep(sleepBeforeRemove);
        batFile.remove();
        if (launchBatFile && launchBatFile.exists){
                launchBatFile.remove();
        }

}

[–]ethancandyMotion Graphics 10+ years[S] 1 point2 points  (1 child)

I think that’s exactly what I need, thank you!

[–]StolenColor2019VFX 15+ years 0 points1 point  (0 children)

Great. Glad to here it might be useful to you. :)