Hi,
I have written a little script which calls on end Process.execute.
As I am a absolute beginner in scripting I can't 'debug' the Process.execute - the only log:
s.log(1, "bla: " + Process.execute(args)
gives me only: bla: 103
Here is the content of args:
args: /Applications/callas pdfToolbox Server 6/cli/pdfToolbox,--mergepdf,-o=/Users/michael/Desktop/bitburg/test/bla.pdf,/Users/michael/Desktop/bitburg/Zwei/_01Y32_test/test_0001.pdf /Users/michael/Desktop/bitburg/Zwei/_01Y32_test/test.pdf
Can anybody see whats wrong here - the pdfToolbox would never called
Here the little Script:
function jobArrived( s : Switch, job : Job )
{
var pfad = job.getPath();
pdftoolbox = s.getPropertyValue('pdftoolbox');
//var pdftoolbox = "/Applications/callas pdfToolbox Server 6/cli/pdfToolbox";
var Ordner = new Dir(pfad);
var PDFDateien = Ordner.entryList("*.pdf", Dir.Files, Dir.Name);
var Sortiert = PDFDateien.reverse();
for ( i=0; i<Sortiert.length; i++) {
if (i<1) {
Ordner = pfad + "/" + Sortiert + " ";
}
else {
Ordner = Ordner + pfad + "/" + Sortiert + " ";
}
}
var args = new Array();
args.push(pdftoolbox);
args.push("--mergepdf");
args.push("-o=/Users/michael/Desktop/bitburg/test/bla.pdf");
args.push(Ordner);
s.log(1, "args: " + args);
Process.execute(args);
}
question about Process.execute
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
question about Process.execute
Hello, the return value for Process.execute() is the exit code of the application. Generally a value of 0 means the process was successful. A non-zero value indicates an error occurred.
If you want the output of the application, use Process.stdout() and Process.stderr().
Dwight Kelly
Apago, Inc.
dkelly@apago.com
If you want the output of the application, use Process.stdout() and Process.stderr().
Dwight Kelly
Apago, Inc.
dkelly@apago.com
question about Process.execute
Hi dkelly,
I could see, what my problem is:
I use Mac OS X 10.8.2, Switch 11 Update 2
I can call a program with process.execute when there are no spaces in file-/foldername.
I tried to escape the spaces with but no reason.
I think I have to call enfocus for this - I could reproduce this on two machines.
But I'm wondering about this, because in one other Script are no problems with process.execute - mmh.
Gruß
Michael
I could see, what my problem is:
I use Mac OS X 10.8.2, Switch 11 Update 2
I can call a program with process.execute when there are no spaces in file-/foldername.
I tried to escape the spaces with but no reason.
I think I have to call enfocus for this - I could reproduce this on two machines.
But I'm wondering about this, because in one other Script are no problems with process.execute - mmh.
Gruß
Michael
question about Process.execute
Hi dkelly,
can you give me an example of Process.stdout and Process.stderr?
I only get: TypeError. 'stdout' undefined or not a function
Gruß
Michael
can you give me an example of Process.stdout and Process.stderr?
I only get: TypeError. 'stdout' undefined or not a function
Gruß
Michael
-
- Newbie
- Posts: 17
- Joined: Mon Dec 13, 2010 4:52 pm
question about Process.execute
Michael,
you should use the following variables to get feedback about the successful call:
var theExitCode = Process.execute(theArgs);
var thestdOut = Process.stdout;
var thestdErr = Process.stderr;
callas pdfToolbox Exit codes can be viewed using the CLI call
./pdfToolbox --status
stdOut and stdErr are strings that need to be parsed for certain information. E.g. using RegExp.
If you have spaces in your path, use " around the path and ' around the string you push. However. Escaping spaces should also work.
You can check if a path is correct by creating a new variable of type DIR and checking the .exists parameter
However, may I ask why you need to script pdfToolbox yourself instead of using the available configurator?
Peter Kleinheider
inpetto
peter@inpetto.cc
you should use the following variables to get feedback about the successful call:
var theExitCode = Process.execute(theArgs);
var thestdOut = Process.stdout;
var thestdErr = Process.stderr;
callas pdfToolbox Exit codes can be viewed using the CLI call
./pdfToolbox --status
stdOut and stdErr are strings that need to be parsed for certain information. E.g. using RegExp.
If you have spaces in your path, use " around the path and ' around the string you push. However. Escaping spaces should also work.
You can check if a path is correct by creating a new variable of type DIR and checking the .exists parameter
However, may I ask why you need to script pdfToolbox yourself instead of using the available configurator?
Peter Kleinheider
inpetto
peter@inpetto.cc
question about Process.execute
Hi Peter,
thank you, but I get the same Error:
29> var theExitCode = Process.execute(args);
30> var thestdOut = Process.stdout();
31> var thestdErr = Process.stderr();
32> s.log(1, "test: " + theExitCode);
33> s.log(1, "Out: " + thestdOut);
34> s.log(1, "Err: " + thestdErr);
Fehler in Zeile 30 des Skripts : TypeError. 'stdout' undefined or not a function
I need to script pdftoolbox, because I you PDF-Split and PDF-Merge, but I have to merge the PDF-Files backwards, and this feature comes only with Version 6.2. And then I don't know if it really works
Gruß
Michael
thank you, but I get the same Error:
29> var theExitCode = Process.execute(args);
30> var thestdOut = Process.stdout();
31> var thestdErr = Process.stderr();
32> s.log(1, "test: " + theExitCode);
33> s.log(1, "Out: " + thestdOut);
34> s.log(1, "Err: " + thestdErr);
Fehler in Zeile 30 des Skripts : TypeError. 'stdout' undefined or not a function
I need to script pdftoolbox, because I you PDF-Split and PDF-Merge, but I have to merge the PDF-Files backwards, and this feature comes only with Version 6.2. And then I don't know if it really works

Gruß
Michael
question about Process.execute
Solved:
The error was the array - now I build the cli manually:
var String befehl = ""/Applications/callas pdfToolbox Server 6/cli/pdfToolbox"" + " " + "--mergepdf" + " " + "-o=/Users/michael/Desktop/bitburg/test/bla.pdf" + " " + Ordner;
Process.execute(befehl);
That works now
Thank you all for your help!
The error was the array - now I build the cli manually:
var String befehl = ""/Applications/callas pdfToolbox Server 6/cli/pdfToolbox"" + " " + "--mergepdf" + " " + "-o=/Users/michael/Desktop/bitburg/test/bla.pdf" + " " + Ordner;
Process.execute(befehl);
That works now

Thank you all for your help!
-
- Newbie
- Posts: 17
- Joined: Mon Dec 13, 2010 4:52 pm
question about Process.execute
That is weird,
as the callas pdfToolbox configurator is also using the array feature to build the command.
Don't know what we did overlook, but it should work as well.
If you want me to have a look at your code don't hesitate to send me your script.
Regards,
Peter Kleinheider
peter@inpetto.cc
as the callas pdfToolbox configurator is also using the array feature to build the command.
Don't know what we did overlook, but it should work as well.
If you want me to have a look at your code don't hesitate to send me your script.
Regards,
Peter Kleinheider
peter@inpetto.cc
question about Process.execute
Hi - that is now my ready Script. It works for me and I know it could be better (for example OutPutFolder of PDF-Merge).
What did the Flow:
1. Rotate Pages 180° (Callas kfpx)
2. Split-PDFs (Callas Action)
3. Rebuild the Pages -> Merge backwards (the Script)
Now I can place the new PDF to an other one and created a "flipping newspaper"
function jobArrived( s : Switch, job : Job )
{
var pfad = job.getPath();
var ausgangsordner = s.getPropertyValue('Ausgangsordner');
var pdftoolbox = """ + "/Applications/callas pdfToolbox Server 6/cli/pdfToolbox" + """;
var name = job.getName();
var ausgangsdatei = ausgangsordner + "/" + name + ".pdf";
var Ordner = new Dir(pfad);
var PDFDateien = Ordner.entryList("*.pdf", Dir.Files, Dir.Name);
var Sortiert = PDFDateien.reverse();
for ( i=0; i<Sortiert.length; i++) {
if (i<1) {
Ordner = pfad + "/" + Sortiert + " ";
}
else {
Ordner = Ordner + pfad + "/" + Sortiert + " ";
}
}
var String befehl = pdftoolbox + " " + "--mergepdf" + " " + "-o=" + ausgangsdatei + " " + Ordner;
Process.execute(befehl);
job.sendToNull(job.getPath());
}
What did the Flow:
1. Rotate Pages 180° (Callas kfpx)
2. Split-PDFs (Callas Action)
3. Rebuild the Pages -> Merge backwards (the Script)
Now I can place the new PDF to an other one and created a "flipping newspaper"
function jobArrived( s : Switch, job : Job )
{
var pfad = job.getPath();
var ausgangsordner = s.getPropertyValue('Ausgangsordner');
var pdftoolbox = """ + "/Applications/callas pdfToolbox Server 6/cli/pdfToolbox" + """;
var name = job.getName();
var ausgangsdatei = ausgangsordner + "/" + name + ".pdf";
var Ordner = new Dir(pfad);
var PDFDateien = Ordner.entryList("*.pdf", Dir.Files, Dir.Name);
var Sortiert = PDFDateien.reverse();
for ( i=0; i<Sortiert.length; i++) {
if (i<1) {
Ordner = pfad + "/" + Sortiert + " ";
}
else {
Ordner = Ordner + pfad + "/" + Sortiert + " ";
}
}
var String befehl = pdftoolbox + " " + "--mergepdf" + " " + "-o=" + ausgangsdatei + " " + Ordner;
Process.execute(befehl);
job.sendToNull(job.getPath());
}
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
question about Process.execute
foxpalace wrote:
29> var theExitCode = Process.execute(args);
30> var thestdOut = Process.stdout();
31> var thestdErr = Process.stderr();
32> s.log(1, "test: " + theExitCode);
33> s.log(1, "Out: " + thestdOut);
34> s.log(1, "Err: " + thestdErr);
Fehler in Zeile 30 des Skripts : TypeError. 'stdout' undefined or
right, stdout and stderr aren't functions they are member variables. Just use
Process.stdout and Process.stderr
ie. no parenthesis
29> var theExitCode = Process.execute(args);
30> var thestdOut = Process.stdout();
31> var thestdErr = Process.stderr();
32> s.log(1, "test: " + theExitCode);
33> s.log(1, "Out: " + thestdOut);
34> s.log(1, "Err: " + thestdErr);
Fehler in Zeile 30 des Skripts : TypeError. 'stdout' undefined or
right, stdout and stderr aren't functions they are member variables. Just use
Process.stdout and Process.stderr
ie. no parenthesis