Hello,
Would it be possible to execute a windows shell command from an eBase script? I'm looking for a way to use Sox ( http://sox.sourceforge.net/ ) to convert .wav files.
Thanks,
Ed
Execute windows shell command from eBase?
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 8
- Joined: Tue Jun 04, 2013 8:13 am
- jig
- Ebase User
- Posts: 30
- Joined: Sun Oct 09, 2011 10:16 am
- Location: UK
Hi Ed,
You can do this by creating and invoking your own Java class (which in-turn executes the cmd/shell command) from an Ebase script.
You have two options for invoking your Java class depending on your Ebase version.
Option 1) Via 'Ebase JavaScript':
a: Import your Java class in Ebase JavaScript and invoke it directly.
OR
b: Create Ebase Custom Resource (Java class) and invoke the same from Ebase JavaScript.
Option 2) Via 'Ebase FPL':
a: Create Ebase Custom Resource (Java class) and invoke the same from Ebase JavaScript.
Hope this helps!
Regards
Jignesh
You can do this by creating and invoking your own Java class (which in-turn executes the cmd/shell command) from an Ebase script.
You have two options for invoking your Java class depending on your Ebase version.
Option 1) Via 'Ebase JavaScript':
a: Import your Java class in Ebase JavaScript and invoke it directly.
OR
b: Create Ebase Custom Resource (Java class) and invoke the same from Ebase JavaScript.
Option 2) Via 'Ebase FPL':
a: Create Ebase Custom Resource (Java class) and invoke the same from Ebase JavaScript.
Hope this helps!
Regards
Jignesh
0 x
Regards,
Jignesh
Jignesh Vaducha, MSc, MCA
Mobile: +44 (0) 77 325 47 112
Telephone: +44 (0) 1462 488 311
Email: jignesh@schnellsolutions.com
Jignesh
Jignesh Vaducha, MSc, MCA
Mobile: +44 (0) 77 325 47 112
Telephone: +44 (0) 1462 488 311
Email: jignesh@schnellsolutions.com
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
You can do this with the Java Runtime class using Javascript on the server. Here is an example of a script that runs the Windows ver command.
I got this from StackOverflow via Google. You can convert pretty much any Java code so it can be executed in Javascript. Here's what the original Java code looks like:
To convert to Javascript, you need to:
o Replace the Java object names on the left-hand side of any assignment statements with Javascript "var".
o Add the fully qualified names of all Java classes (or use importPackage statements).
o Change any try/catch statements to Javascript format (there aren't any in this example).
I've also changed the System.out.println() statement to log() to see the output, but this is not a requirement to get it working.
You can use this approach to run pretty much all Java code.
Regards
Jon
Code: Select all
var p = java.lang.Runtime.getRuntime().exec("cmd /C ver");
var stdInput = new java.io.BufferedReader(new java.io.InputStreamReader(p.getInputStream()),8*1024);
var stdError = new java.io.BufferedReader(new java.io.InputStreamReader(p.getErrorStream()));
// read the output from the command
var s = null;
while ((s = stdInput.readLine()) != null)
{
log(s);
}
Code: Select all
Process p = Runtime.getRuntime().exec("cmd /C ver");
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()),8*1024);
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
String s = null;
while ((s = stdInput.readLine()) != null)
{
System.out.println(s);
}
o Replace the Java object names on the left-hand side of any assignment statements with Javascript "var".
o Add the fully qualified names of all Java classes (or use importPackage statements).
o Change any try/catch statements to Javascript format (there aren't any in this example).
I've also changed the System.out.println() statement to log() to see the output, but this is not a requirement to get it working.
You can use this approach to run pretty much all Java code.
Regards
Jon
0 x
Who is online
Users browsing this forum: No registered users and 24 guests