Copy link to clipboard
Copied
Dear All,
How to run the ".sh" file through Adobe InDesign Javascript, I used the below coding:
//================== Code =============================//
var myFile = File("xxx/xxx/xxx/Test.sh");
var Exec = "sh" + " "+ "\""+myFile+"\"";
File(Exec).execute();
//================== End =========================//
the above coding is not working, I checked before without "sh" also, It is not working.
Please anyone can give me the solutions & suggestion, and I will appreciate.
Thanks & Regards
T.R.Harihara SudhaN.,
Does your file IDMLExportparse.sh have execute permissions set?
If you open Terminal.app and type
/Applications/MacXinPro/IDMLExportparse.sh
does it work? Or do you need to run "sh"? If so, either adjust the
permissions with
chmod a+x /Applications/MacXinPro/IDMLExportparse.sh
or change the JavaScript to:
shell("sh "+myFile);
Copy link to clipboard
Copied
You can't do it. Your only choice is to use VB or AppleScript, as appropriate for your platform, to call the shell.
This is what I use under OS X:
function shell(cmd) {
var
rv,
call ='do shell script "'+
cmd.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+
'"';
try {
rv = app.doScript(call,
ScriptLanguage.APPLESCRIPT_LANGUAGE);
} catch(e0) {
rv = e0+"\n"+(rv?"":rv);
}
return rv;
}
Copy link to clipboard
Copied
Dear Hawkinson,
Many thanks for this quick reply, I'm really very happy, but unfortunately the script is return the "Permission denied" value.
I used the below code, Please kindly change if anything is wrong.
//====================== Script Source =====================//
var myFile ="/Applications/MacXinPro/IDMLExportparse.sh";
shell(myFile);
function shell(cmd) {
var
rv,
call ='do shell script "'+ cmd.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"';
try {
rv = app.doScript(call,ScriptLanguage.APPLESCRIPT_LANGUAGE);
} catch(e0) {
rv = e0+"\n"+(rv?"":rv);
}
return rv;
}
//====================== End : Script Source =====================//
//=========== Output ================//
Execution finished. Result: Error: sh: /Applications/MacXinPro/IDMLExportparse.sh: Permission denied
undefined.
Please kindly help me...
Thanks & Regards
T.R.Harihara SudhaN
Copy link to clipboard
Copied
Does your file IDMLExportparse.sh have execute permissions set?
If you open Terminal.app and type
/Applications/MacXinPro/IDMLExportparse.sh
does it work? Or do you need to run "sh"? If so, either adjust the
permissions with
chmod a+x /Applications/MacXinPro/IDMLExportparse.sh
or change the JavaScript to:
shell("sh "+myFile);
Copy link to clipboard
Copied
Message was edited by: Harihara Sudhan
Copy link to clipboard
Copied
Hmm...looking back at my script I notice now:
} catch(e0) { rv = e0+"\n"+(rv?"":rv);
I'm not quite sure what I was thinking here. I think the ?: is backwards and this was intended to be (rv?rv:"") but that doesn't really make sense either, since that's the same as (rv), and rv never gets set if there's an exception anyhow. so it could have just been: rv = e0;
Oh well... It doesn't break anything, just looks ugly.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more