Passing arguments to the jsx file from command line

Thanks for taking my question.
I am using the following to be able to run my script from the command line.In case you were wondering on why i would be doing this- i would need to invoke the javascript from a server side code(like java,php etc. in my case it is java)
"c:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit\ExtendScript Toolkit.exe" "c:\path to script\myscript.jsx"
Anyways, i have been successful in running the myscript.jsx from the command line but i am not able to figure out how i could pass arguments to "myscript.jsx" from the command line, and be able to refer to these arguments within the script.
I have tried the following
"c:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit\ExtendScript Toolkit.exe" "c:\path to script\myscript.jsx" "argument1" "argument2"
and tried to refer these arguments within the script using arguments[0] and arguments[1] . But looks like this does not work.
Any thoughts?????

To run JavaScript from the prompt using ExtendScript Toolkit 1.0.3 or 2.0.2 you need to do the following:
Add the line #target indesign to the top of your script otherwise ESTK will open without executing the script. Example:
#target indesign
//MakeDocumentWithParameters.jsx
//An InDesign CS2 JavaScript
//Shows how to use the parameters of the document.open method.
//The first parameter (showingWindow) controls the visibility of the
//document. Hidden documents are not minimized, and will not appear until
//you add a new window to the document. The second parameter (documentPreset)
//specifies the document preset to use. The following line assumes that
//you have a document preset named "Flyer" on your system.
var myDocument = app.documents.add(true, app.documentPresets.item("Flyer"));
//SaveDocumentAs.jsx
//An InDesign CS2 JavaScript
//If the active document has not been saved (ever), save it.
if(app.activeDocument.saved == false){
//If you do not provide a file name, InDesign will display the Save dialog box.
app.activeDocument.save(new File("/c/temp/myTestDocument.indd"));
Ensure Indesign is open. Execute the following command:
"C:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit\ExtendScript Toolkit.exe" -run "[path to script]\script.jsx"
For example:
"C:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit\ExtendScript Toolkit.exe" -run "C:\Program Files\Adobe\Adobe InDesign CS2\Presets\Scripts\test.jsx"
This command can be easily called from Java or any other third party application of your choice.
It took me a while to find this information, so I thought I'd share it with everyone.
Good luck!

Similar Messages

  • How to pass arguments to a batch file from java code

    Hi
    I have a batch file (marcxml.bat) which has the following excerpt :
    @echo off
    if x==%1x goto howto
    java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; %1 %2 %3
    goto end
    I'm calling this batch file from a java code with the following line of code:
    Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat");
    so ,that invokes the batch file.Till that point its ok.
    since the batch file accpets arguments(%1 %2 %3) how do i pass those arguments to the batch file from my code ...???
    %1 is a classname : for ex: gov.loc.marcxml.MARC21slim2MARC
    %2 is the name of the input file for ex : C:/Downloads/Marcxml/source.xml
    %3 is the name of the output file for ex: C:/Downloads/Marcxml/target.mrc
    could someone help me...
    if i include these parameters too along with the above line of code i.e
    Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat gov.loc.marcxml.MARC21slim2MARC C:\\Downloads\\Marcxml\\source.xml C:\\Downloads\\Marcxml\\target.mrc") ;
    I get the following error :
    Exception in thread main java.lang.Noclassdef foundError: c:Downloads\marcxml\source/xml
    could some one tell me if i'm doing the right way in passing the arguments to the batch file if not what is the right way??
    Message was edited by:
    justunme1

    1 - create a java class (Executer.java) for example:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    public class Executer {
         public static void main(String[] args) {
              try {
                   for (int i = 0; i < args.length; i++) {
                        System.out.println(args);
                   Class<?> c = Class.forName(args[0]);
                   Class[] argTypes = new Class[] { String[].class };
                   Method main = c.getDeclaredMethod("main", argTypes);
                   // String[] mainArgs = Arrays.copyOfRange(args, 1, args.length); //JDK 6
                   //jdk <6
                   String[] mainArgs = new String[args.length - 1];
                   for (int i = 0; i < mainArgs.length; i++) {
                        mainArgs[i] = args[i + 1];
                   main.invoke(null, (Object) mainArgs);
                   // production code should handle these exceptions more gracefully
              } catch (ClassNotFoundException x) {
                   x.printStackTrace();
              } catch (NoSuchMethodException x) {
                   x.printStackTrace();
              } catch (IllegalAccessException x) {
                   x.printStackTrace();
              } catch (InvocationTargetException x) {
                   x.printStackTrace();
              } catch (Exception e) {
                   e.printStackTrace();
    2 - create a .bat file:
    @echo off
    java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; Executer %TARGET_CLASS% %IN_FILE% %OUT_FILE%3 - use set command to pass variable:
    Open MS-DOS, and type the following:
    set TARGET_CLASS=MyTargetClass
    set IN_FILE=in.txt
    set OUT_FILE=out.txt
    Then run your .bat file (in the same ms dos window)
    Hope that Helps

  • Running Unit Test from test manager that run bat file from command line

    Hi ,
    I am trying to run Jsystem (java framewotk) from command line using runScenario.bat thru unit test that i associated to test in test manager.
    the idea is that when i ran the automated test  from MTM - it will run the the unit test that will run the appropriate test case in java.
    i wrote the code like this : 
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    namespace UnitTestProject3
    [TestClass]
    public class UnitTest1
    [TestMethod]
    public void TestMethod1()
    try
    String command = "c:\\JSYSTEM\\runner\\runScenario.bat
    c:\\Users\\ryeshua\\Source\\Workspaces\\Auto1\\my-tests-project\\target\\classes scenarios\\feature1 RoeySetup.xml ";
    System.Diagnostics.ProcessStartInfo procStartInfo =
    new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
    procStartInfo.RedirectStandardOutput = true;
    procStartInfo.UseShellExecute = false;
    //procStartInfo.CreateNoWindow = true;
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.StartInfo = procStartInfo;
    proc.Start();
    string result = proc.StandardOutput.ReadToEnd();
    Console.WriteLine(result);
    catch (Exception objException)
    // Log the exception
    and when i ran it from visual studio it worked perfect. and update  the Jsystem logs of the junit test in the jsystem/runner/log folder.
    but when i added it to associated test and ran it from MTM - it pass but it does not update  the logs in jsystem folder.
    the problem that i dont know what is not working. i cant see the output of it when i ran from mtm but can see when i ran from VS.
    i am using VS 2013 Pro with MTM 2013.
    please advice
    Roey

    Hi Roey,
    Thank you for posting in MSDN forum.
    Based on your issue, could you please tell me how you generate the log file under the jsystem folder?
    Generally, I know that when we run unit test from VS IDE, the file will be saved into the local machine. But when we run unit test from MTM, the unit test method will be run on the test agent machine, so the file will be saved into the test agent machine.
    Therefore, I suggest you could check if you did not see the updated logs file in jsystem folder on the test agent machine.
    In addition, I suggest you could try to copy this unit test project on this test agent machine and then run the unit test method using mstest.exe in command line and then check if you can update the logs file.
    https://msdn.microsoft.com/en-us/library/ms182489.aspx?f=255&MSPPError=-2147217396
    If you have any updated message about this issue, please tell me.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Can't run JavaFX app as a jar file from command line

    I'm trying to build a JavaFX app from scratch (that is, by including the jar file from the JavaFX SDK rather than by using the special JavaFX project type from NetBeans). It runs fine in NetBeans. However, when I try to launch it as a jar file from the command line (using "java -jar dist\TestApp") I get the following. Has anybody seen this before, and if so how can I fix it?:
    *** Fallback to Prism SW pipeline
    Exception in thread "main" java.lang.RuntimeException: java.lang.UnsatisfiedLink
    Error: Can't load library: C:\dev\TestApp\dist\bin\mat.dll
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
    289)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:68)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherIm
    pl.java:145)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:
    27)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:97)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\dev\RedactionT
    oolPrototype\RedactionToolPrototype.Core\dist\bin\mat.dll
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoad
    er.java:155)
    at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoad
    er.java:85)
    at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:
    30)
    at com.sun.glass.ui.Application$1.run(Application.java:28)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:26)
    at com.sun.glass.ui.win.WinApplication.<clinit>(WinApplication.java:33)
    at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
    Factory.java:20)
    at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
    Factory.java:17)
    at com.sun.glass.ui.Application.Run(Application.java:51)
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
    279)
    ... 5 more

    Unsatisfied link means that Java is trying to access a native library, but it cannot be found. As to why this error is being thrown, here is my guess:
    If you open up one of the sample jars with a zip viewer, you will see that the Manifest file has the following entries:
    >
    Manifest-Version: 1.0
    JavaFX-Version: 2.0
    implementation-vendor: Oracle
    implementation-title: BrickBreaker
    implementation-version: 1.0
    JavaFX-Application-Class: brickbreaker.Main
    Created-By: JavaFX Packager
    Main-Class: com/javafx/main/Main
    >
    In other words, a JavaFX project works a bit differently than a normal Java project. com/javafx/main/Main is used as the Main class and your "Main" class is called later.
    If you are trying to build this from a normal Java project, then com/javafx/main/Main will not be created and it will call your Main class right away. Thus, whatever setup is needed to run JavaFX will not occur.

  • How to specify xml file to populate form fields in the PDF file via command line?

    Hi,
    I would like to specify xml data file to populate my pdf file using command line.
    The form was Reader extended.
    I've tried the following syntax :
    Acrobat.exe /A "zoom=100" "C:\example.pdf"#xml="C:\example.xml" but got an acrobat error: "the file name, directory name or volume label syntax is incorrect".
    Where am I wrong?
    Thanks!

    >If I understand correctly you propose something like this
    Something like, yes.
    >
    >Acrobat.exe /A "zoom=100" "xml=C:\example.xml" ....
    Certainly, neither will work. /A is followed by a single quoted
    string. There must be some separator, but I don't know what it needs
    to be (as I was alluding to in my first reply).
    To see if there is any hope, just try without the zoom= completely. In
    any case you can set the zoom in the document properties.
    Aandi Inston

  • Run PDF File from command line and goto a bookmark

    Hi,
    I need to open a pdf file vi command line (WinXP / Win7).
    Till this I do not have a problem.
    But I need to go to a bookmark in the file direct after opening the file.
    I tried "acrord23.exe /a nameddest=BOOKMARK file.pdf" but this opened only the file.
    "acrord23.exe /a zoom=50 file.pdf" works fine.
    Is there another parameter to go to a bookmark after open a file?
    Where is my mistake?
    Thanks in advance
    Regards
    Marc
    Message was edited by: mgemmerich - reason: typo

    Hi,
    I read the PDF Open Parameters reference. So I tried the nameddest. I think the nameddest is a bookmark, or is this wrong?
    The background is, that we have the dokumentation for our application in word. So we save the word as pdf. Each chapter is now a bookmark.
    In the application we want to call the pdf and jump to the bookmark. Each frame were you can call "help" is a chapter/bookmark.
    Or is there another way to do this?
    Regards
    Marc

  • Changing the override file via command line arguments

    Is there a way to change name of the file Coherence uses to override coherence-config.xml via a command line argument? I'd like to specify different override filenames in different environments.

    I get the message that:
    2006-02-13 16:53:27.699 Tangosol Coherence 3.0.1/317 <D5> (thread=main, member=n/a): Optional configuration file "/home/noah/tools/tangosol-config/tangosol-coherence-override-dev.xml" is not specified
    I specified the following as the startup:
    java -Dtangosol.coherence.override=/home/noah/tools/tangosol-config/tangosol-coherence-override-dev.xml -Dtangosol.coherence.log.level=5 -classpath /home/ncohen/tools/tangosol-config:/home/noah/tools/tangosol/lib/coherence.jar com.tangosol.net.CacheFactory
    Where the tangosol-config directory contains my override file tangosol-coherence-override-dev.xml
    If I change the name of the override file solely in the cmd prompt, it doesn't find any of them. It just gives me the optional configuration file ..... is not specified. How does one go about fixing this? Thx.
    Message was edited by:
    noah

  • Can't open .term Terminal.app files from command line

    Howdy. I use Terminal.app constantly for ssh'ing into numerous remote machines. On my G4 Powerbook I have simply created .term files with customized colors, titlebars, and an appropriate ssh execution string for each machine/userid combination, which I am able to open with "open ~/bin/foo.term". Life is no longer so joyously simple on my new Intel iMac. I create a .term file (via Cmd-s while in a terminal window), but the above command to open foo.term now simply doesn't work on my iMac once a single terminal window has been opened (even after it's been closed) -- I can start one such file only from the finder or via Launchbar or Quicksilver. The only way I can use my .term files is by switching to Terminal and selecting File...Open and clicking on the .term file -- which, being a command line (and Launchbar) junkie, I hate, of course. Applescripts don't work either.
    I would be forever grateful if someone could tell me how to fix this problem!
    txlogic
    Intel iMac Mac OS X (10.4.6)
    iMac   Mac OS X (10.4.6)  

    TXLogic
    I cannot do it either.
    Ah, interesting -- thanks for the input. I had thought the problem might have something to do with the fact that I was using an Intel iMac, but you are using a PPC iBook. The problem isn't with 10.4.6 either, as that is what I'm running on my G4 Powerbook, and the .term files work as expected on that machine.
    Initially I thought it was a
    problem with permissions, i.e the term file hadn't
    the execute bit set (which it did not). Setting the x
    bit though did not help at all.
    Right, the .term files aren't executable.
    A work around was to
    save the command(s) into a plain text document in
    text edit (not rtf) as a .command file (no txt
    extension in this case) and set its execute bit in
    terminal (sudo chmod u+x ...).
    I don't quite understand the workaround -- what command(s) exactly did you put into the .command file? Could you paste the contents of such a file here?
    I have not dealt with term files extensively but I
    noticed that .term files are xml ones. Could anyone
    shed some light in possible changes in the way
    terminal handles them?
    Since the .term files work as desired on my Powerbook, it now doesn't appear that Terminal.app has changed its processing of the files. Something else is going on here.
    txlogic

  • How to launch a specific TestStand sequence file from command line?

    I've written a TestStand sequence file launching other sequence files.
    When I launch it via the TestStand GUI, it works well.
    Now, I would like to launch it via command line. Could you indicate me how to proceed?

    Hi,
    I think this link can help you:
    How to Run a Sequence File When Opened from Windows Explorer
    http://digital.ni.com/public.nsf/websearch/146D372C1F807E6D862567E7004881AB?OpenDocument
    regards,
    Alexandre D
    NIF

  • Emacs auctex menus empty when not opening file from command line

    I have got a problem with emacs/auctex.
    In a running emacs editor, if I am opening a .tex file out of the editor, the menus "LaTeX", "Command" and "Math" are empty. That is, upon clicking on them, there is no dropdown list:
    Example: http://img8.imageshack.us/img8/7285/ema … ommand.jpg
    If, however, I open a .tex file from the console by invoking emacs
    $ emacs file.tex
    the menus show up the way they should.
    My .emacs
    (custom-set-variables
    ;; custom-set-variables was added by Custom.
    ;; If you edit it by hand, you could mess it up, so be careful.
    ;; Your init file should contain only one such instance.
    ;; If there is more than one, they won't work right.
    '(inhibit-startup-screen t))
    (custom-set-faces
    ;; custom-set-faces was added by Custom.
    ;; If you edit it by hand, you could mess it up, so be careful.
    ;; Your init file should contain only one such instance.
    ;; If there is more than one, they won't work right.
    ;; Auctex
    (load "auctex.el" nil t t)
    (setq TeX-auto-save t)
    (setq TeX-parse-self t)
    (setq-default TeX-master nil) ; Query for master file.
    (setq TeX-PDF-mode t) ;; set pdflatex default, not latex
    (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode) ;; set math mode
    What am I missing?
    Edit: I am running linux 2.6.31 x86_64, emacs 23.1-3, auctex 11.85-2
    Last edited by fubar0 (2009-10-22 22:44:48)

    Me too. Same kind of problem with Dired also: the menus are empty. I've even gone so far as to reinstall a fresh Archlinux, although not just for this purpose (I just had to try the Beta Fedora 12, but it crashed all over the place. It lasted about an hour on my machine). I know that if I had any business using Emacs I should know how to fix this, but I don't have a clue. It's been happening for a couple weeks now. And just to reiterate, this is a clean install, I haven't messed with it at all, I don't even have a custom .emacs to show. I haven't looked to see if this empty menu thing happens anywhere else or not--these are just the two things I use emacs for.
    I don't see a bug report for this, but I don't feel I have the qualifications to submit a good bug report, so I'm hoping someone qualified will hear our crys for help. Forgive my ignorance, this is my first time posting on here.

  • Install Adobe Air application (.air file) from command line in Mac OS X

    Hello everybody
    I would like to install an air application on many systems (Mac OS X) using remote install. Is there a way to achieve this?
    Is there a pure command line utility to install Adobe AIR applications (.air files) in Mac OS X?
    Thanks. Masteradi

    Thanks for your reply. I already knew that command but it's good to see it again.
    In the meantime I have found a tool called ARH (AIR Redistribution Helper) which can be used to install an air application, uninstall an air application, etc.
    Now I would like to create a .pkg file (for Mac OS X) that will use ARH together with my .air file and that will install or update (uninstall/install) the application. But I guess this is no more an issue for Adobe AIR. I have to learn the tools specific for Mac (Iceberg, Xcode).
    Best regards
    Masteradi

  • Is there a way to set the binding policy from command line?

    I'm unable to save the Binding Policy setting "Allow users to edit their own contact information" using the server admin gui. I click it and press save, but the checkbox clears when the spinner at the bottom stops.
    I'd love to know where this setting resides or if it can be set via the command line.

    I've finally found a solution to this!
    Open the "all records" tab in workgroup manger, and find the OLCBDBConfig from the dropdown list.
    Go to "{1}bdb" and expand "dsAttrTypeNative:olcAccess(23)", then edit the "{0}to" entry.
    On my OD it was set like this:
    {0}to dn.onelevel="cn=users,dc=mydomain,dc=com" attrs=apple-mcxflags,apple-mcxsettings by set="user/uid & [cn=admin,cn=groups,dc=mydomain,dc=com]/memberUid" write by sockurl="ldapi://%2Fvar%2Frun%2Fldapi" write by dn.exact="cn=myserver.mydomain.com$,cn=computers,dc=mydomain,dc=com" write by * read
    While it should read like this:
    {0}to dn.one="cn=users,dc=mydomain,dc=com" attrs=@apple-user-info by set="user/uid & [cn=admin,cn=groups,dc=mydomain,dc=com]/memberUid" write by sockurl="ldapi://%2Fvar%2Frun%2Fldapi" write by dn.exact="cn=myserver.mydomain.com$,cn=computers,dc=mydomain,dc=com" write by self write by * read
    Note that I have an LDAP search policy of mydomain.com and a FQDN of myserver.mydomain.com.
    I had to change bit by bit, starting with "dn.onelevel" to "dn.one", then "attrs" and finally the "write" part at the end.

  • Parental Control, how can I know the remaining time (from command line)

    Hello,
    I did setup Parental Control on my kid's iMac.
    I configured a "Weekday Time Limit". On their desktop, they can get the information about the remaining time by clicking simply on the clock.
    I would like to know how I can get this information while I am connected via ssh
    Thank you in advance.

    Apparently all the Parental Controls preferences files are stored here:
    /Library » Application Support » Apple » ParentalControls » Users » username
    I imagine somewhere in there it keeps a record of the remaining time etc.  You'll need root authority to access Users onwards.

  • I need to call a batch file from java and pass arguments to that Batch file

    Hi,
    I need to call a batch file from java and pass arguments to that Batch file.
    For example say: The batch file(test.bat) contains this command: mkdir
    I need to pass the name of the directory to the batch file as an argument from My Java program.
    Runtime.getRuntime().exec("cmd /c start test.bat");
    How to pass argument to the .bat file from Java now ?
    regards,
    Krish
    Edited by: Krish4Java on Oct 17, 2007 2:47 PM

    Hi Turing,
    I am able to pass the argument directly but unable to pass as a String.
    For example:
    Runtime.getRuntime().exec("cmd /c start test.bat sample ");
    When I pass it as a value sample, I am able to receive this value sample in the batch file. Do you know how to pass a String ?
    String s1="sample";
    Runtime.getRuntime().exec("cmd /c start test.bat s1 ");
    s1 gets passed here instead of value sample to the batch file.
    Pls let me know if you have a solution.
    Thanks,
    Krish

  • How can pass the data from Command line  to  Applet?

    Hi,
    I am writing a chat application by using sockets. For that purpose I need to pass the parameter data from command line to Applets. Is there any method to receive command line args data in Applets? If so please tell me.

    Passing command line arguments to an applet is not possible, but for the same you can try using param tags, within your applet tag.
    For eg:
    <applet.......>
    <param name="xyz" value="abcdef">
    </applet>
    Within the applet's any method like init call <getParameter("xyz");>
    will return u the value.
    [email protected]

Maybe you are looking for