Runtime.exec() - Strips the parameter list on encountering a newline(\n)
I am executing a batch file from Runtime.exec() and i am passing a list of parameters to the batch file in the form of name=value pairs.One of the parameters value is a multiline text containing "\n" characters.i.e input from a textarea.
When my program executes the batch file it prints all the parameters till it encounters the "\n" character and strips all the remianing parameters.And it does not show any error .
Is this a bug of Runtime.exec method ?
If not, how to resolve this problem?
Bug in Runtime.exec? Nope, it's probably you and your code.
Read this - everyone who uses Runtime.exec should:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Similar Messages
-
What is the parameter list and why does it keep on coming up?
What is the parameter list and why does it keep on coming up when I try to finalize the video or share it?
Hi
I try to finalize the video or share it?
How do You do that and to what do You Share it ?
Yours Bengt W -
Passing Java statements in the parameter list
I am relatively new to Java and have a need to create a method which has a Java statement passed to it in the parameter list. The purpose is to optionally run this statement within the method. For example:
I have a method called rotateAndTranslate that sets up an Affine Transform by saving the existing transform context, creating a new transform, and then invoking that transform. After the new transform is invoked, I would like to have the ability to run different Java graphics commands (or not) before continuing with the remaining portion of the existing method (in this case, restoring the previous transform.
I am not able to find any clear information on how to pass in Java statements and then invoke them.
Can someone help with this? Please keep it simple as I am still trying to get my head around Java and OOP.
Carlyou're talking about closures, more or less, which java doesn't currently have
you can get close to it by using anonymous inner classes. define an interface, say Transformer, and pass instances of that as arguments:
public interface Transformer {
void transform();
Transformer transformer = new Transformer() {
public void transform() {
// do the work here
MyTransformerClass.doTransform(transformer);
...obviously, the MyTransformerClass.doTransform() must take a Transformer as a parameter -
Runtime Error for the Picking List Smartform
Hi All,
I am working on the smartform, used for GI Scrapping for 551 Movement type. The requirement is they need DEA number for the Plant. I have written code for getting the DEA number. Iacivated the form and I want to print it using the TCODE MB02.
I get the runtime error saying UPDATE TERMINATED.I saw Dump Analysis it says CALL_FUNCTION_PARM_MISSING. It says IS_ADRC is the parameter. The ABAP program is the include program /SMB40/M07DRSON. This show the function module lf_fname with out passing the parameter IS_ADRC. How can I change the program. This is Standard program.
Thanks,Then the smart form interface in the transaction SMARTFORMS you have to remove the parameter IS_ADRC. As the calling program will not automatically add the parameters if you add it in the smartforms...
If you want the values from the table ADRC..you can write subroutines in the INITIALIZATION to get the values...
Thanks,
Naren -
Runtime.exec ignores the working directory argument
Hi Folks,
I need to run a batch file in a particular directory, from a Java program.
Here, I want to run "startMySQL.bat" from the ./bin directory.
I used the following code to do so.
String commandToExecute = "startMySQL.bat";
File file = new File("bin");
Process sqlPrcs = Runtime.getRuntime().exec(commandToExecute, null, file);
When I run these lines in a program, I get the following exception:
java.io.IOException: CreateProcess: startMySQL.bat error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at com.aperto.ems.packetmax.AuthenticationScreen.startDB(AuthenticationScreen.java:603)
at com.aperto.ems.packetmax.AuthenticationScreen.validateUserAndReinitialize(AuthenticationScreen.java:479)
at com.aperto.ems.packetmax.AuthenticationScreen.access$0(AuthenticationScreen.java:468)
at com.aperto.ems.packetmax.AuthenticationScreen$OnOKButtonPress.actionPerformed(AuthenticationScreen.java:628)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener$ReleasedAction.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
"error=2" in Windows mean "not able to find the file".
Any clues on how I can run the batch file from a particular working directory?
Thanks!Hi,
I changed the code to print the user.dir output and the absolute path of the file. It looks like this:
String commandToExecute = "startMySQL.bat";
File fl = new File("bin");
System.out.println(fl.getAbsolutePath());
System.out.println(System.getProperty("user.dir"));
Process sqlPrcs = Runtime.getRuntime().exec(commandToExecute, null, fl);
Below is the output I get:
C:\Program Files\Aperto\WaveCenter\Back-End_Server_2.0_build8\bin
C:\Program Files\Aperto\WaveCenter\Back-End_Server_2.0_build8
java.io.IOException: CreateProcess: startMySQL.bat error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at com.aperto.ems.packetmax.AuthenticationScreen.startDB(AuthenticationScreen.java:604)
at com.aperto.ems.packetmax.AuthenticationScreen.validateUserAndReinitialize(AuthenticationScreen.java:479)
at com.aperto.ems.packetmax.AuthenticationScreen.access$0(AuthenticationScreen.java:468)
at com.aperto.ems.packetmax.AuthenticationScreen$OnOKButtonPress.actionPerformed(AuthenticationScreen.java:629)
I assure you, "startMySQL.bat" is there under "bin"
Thanks,
Sandeep -
Runtime.exec - hidding the ugly black dos window
Hello,
Could someone tlle me how to hide the dos command which is always opened when using Runtime.exec on a windows OS?
I also know that there's already lots of questions already posted on this subject but I can't find them.. So links could help me....
LoicHere's what came up when I searched the forum using "hide runtime":
http://search.java.sun.com/Search/java?col=javafrm&qp=%2Bforum%3A31&qt=hide+runtime&x=10&y=10 -
How to Display values in order when Multiple values are selected in the Parameter List
<p>Hi</p><p>I have a report which runs on the parameter(SalesPersonName) selected.<br />Report has a group section where for each SalesPersonName we have different actions(Lead,Prospect,Active and so on) he had performed which is the basis for the group.</p><p>Now if i need multiple Value selection in the parameter,which i am able to acheive but the order in which it gets printed is not the right one.</p><p>I want intially all the actions performed by one sales person printed and then the second one should start.</p><p>Can any one help me in this aspect.</p><p>Thanks in advance</p>
<p>If I understand your report structure correctly - you have one Grouping on Actions. So could you not add another grouping on SalesPersonName above the Actions grouping that you currently have?</p><p>So the new structure would be:</p><p>G1 - SalesPersonName</p><p>G2 - Actions (current grouping you have)</p><p> </p><p>Whether or not you suppress or don't suppress the new grouping is your choice, but it will then force the ordering that you are asking about (assuming I understood) </p>
-
Multiple Label fields within the Parameter List of Available Values
Hi,
I have a business requirement where this is a period number which will be a value filed within a parameter. The labels of the parameter need to be the start date of the period and the end date of the period. What is the best way implement this in SSRS please?
Since SSRS seems to be limited to one label field. My best quess at a solution is to concatinate the start and end period into a single field then expose this as the label.
Is this the best approach to take?
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/You need to modify the dataset to concatenate start and end periods to get new field which can be used as your label field.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Import type for updating the parameter list to integrator-WEBADI
Hi,
Can anyone tell what are the import_type = 1,2,3,4,5 for updating the param list in the integrator for WEBADI.
I know only that impot_type=3 is for procedure. what about 1,2 and 4.hi
I knew that about import_type is as follows:
1 Asynchronous concurrent request
2 Synchronous concurrent request
3 PL/SQL API
4 not knew
regards,
leno -
How to specify delimiter when parsing the parameter list in URL
Here is a sample URL used to call the servlet:
http://myhost.com/servlet?param1=test1¶m2=test2¶m3=test3In the doGet method of my servlet, I understand I can use the getParameter method to retrieve the various parameter values:
String p_param1 = request.getParameter("param1");
String p_param2 = request.getParameter("param2");
String p_param3 = request.getParameter("param3");However, what if the URL was of the form:
http://myhost.com/servlet?param1=test1+param2=test2+param3=test3where the URL parameter delimiter was a plus sign rather than an ampersand (&).
By default, the servlet is only recognizing the ampersand (&) as a parameter delimiter.
When I use a plus sign as the delimiter, getParameter retrieves everything after the question mark (?) as the first parameter
i.e. param1 = test1 param2=test2 param3=test3
param2 = null
param3 = null
How can I get getParameter to recognize a plus sign (+) as a valid delimiter?Servlets follow the HTTP specification. So, there is not much you can do on that level. What you could do (though I do not recommend it) is to set-up a filter that will automatically swap the plus with an ampersand before the actual servlet processes it. My strong advice, however, is to give up on using a nonstandard delimiter.
[http://java.sun.com/products/servlet/Filters.html]
- Saish -
The Runtime.exec methods doesn't work well on Solaris ???
I have two threads and I set the different running time.
I use Runtime.exec to a run the command and use Process to get the process.
It works properly in the windows2000 platform.
However, when I transfer the platform to Solaris...and run the program...
Two threads always at the same time....It is very wired....I always debug
for 2 days....
(at first I run "vmstat 1 2" command, later I change to "ls","rmdir"....etc,
all of them don't work.....
If I close the Runtime.exec..........Everything works well......)
And I study the API. I found this message...
The Runtime.exec methods may not work well for special processes on certain
native platforms, such as native windowing processes, daemon processes,
Win16/DOS processes on Win32, or shell scripts. The created subprocess does
not have its own terminal or console.
Could someone share her/his experience.....:(
And if any other way I can run command inside java code instead of
Runtime.exec.....???
Please reply my mail to [email protected] I do appreciate your kindly &
great help!!!!!!!!
This is my code.......
import java.io.*;
import java.lang.*;
import java.util.*;
* <p>ServerThread1</p>
* <p>??�X???��?�D???�X???, "Vmstat 1 2".</p>
class ServerThread1 extends Thread{
private ServerAgent Sa;
public ServerThread1 (String Name, ServerAgent Sa){
super(Name);
this.Sa = Sa; file://Assign ServerAgent reference Sa
public void run(){
while(true){
try{
Thread.sleep(5000);
catch (Exception e){
System.out.println("ServerThread1 fails");
System.out.println("Thread1 is running.");
try {
Runtime rt1 = Runtime.getRuntime();
Process proc1 = rt1.exec("mkdir"); ------>If I close
rt1.exec , two threads works seperately...........:(
catch (Exception e) {
System.out.println("Thread1 Error");
class ServerThread2 extends Thread{
private ServerAgent Sa;
public ServerThread2 (String Name, ServerAgent Sa){
super(Name);
this.Sa = Sa;
public void run(){
while(true){
try{
Thread.sleep(15000);
catch (Exception e){
System.out.println("ServerThread2 fails");
System.out.println("Thread2 is running.");
try {
Runtime rt2 = Runtime.getRuntime();
Process proc2 = rt2.exec("vmstat 1 2"); ----->If I don't run
the rt2.exe, two threads work seperately....
catch (Exception e) {
System.out.println("Thread2 Error");
public class ServerAgent{
private Vector v1 = new Vector();
private Vector v2 = new Vector();
private Hashtable currentData = new Hashtable();
private static String startUpSwap = null;
private static String startUpMem = null;
public static void main(String[] arg) {
ServerAgent s = new ServerAgent();
ServerThread1 st1 = new ServerThread1("Thread1",s);
ServerThread2 st2 = new ServerThread2("Thread2",s);
st1.start();
st2.start();If I close the Runtime.exec..........Everything works
well......)You don't empty the output of the command, that blocks the process.
A citation from
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Why Runtime.exec() hangs
The JDK's Javadoc documentation provides the answer to this question:
Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.
Try out something like this:
String s;
try {
Process myProcess =
Runtime.getRuntime().exec("ls -l"));
DataInputStream in = new DataInputStream(
new BufferedInputStream(myProcess.getInputStream()));
while ((s = in.readLine()) != null) {
out.println(s);
catch (IOException e) {
out.println("Error: " + e);
}Another source of trouble under Unix is not having the correct permission for that user that executes the Java VM, which will be the permissions for the spawned subprocess. But this probably not the case, as you see something after exit.
Regards,
Marc -
Introduction
There is a scenario that thousands of values in the drop-down of a parameter. Scrolling through the large drop down list is slow and cumbersome. Is there a way that we add a search feature in the report, so that it can filter down the values in the drop
down list to a smaller list of values?
Solution
To achieve this requirement, we can add a parameter with multiple keywords ahead, then all of available values which are begin with the keyword will display in the parameter list. In this scenario, we can create cascading parameters. One is a keyword parameter,
and the other parameter is based on the keyword to display the available values.
In order to enable the user to type multiple keywords, we can use the query below to create a split function which takes the list and the de-limiter as input parameters and splits all the values in the database:
CREATE FUNCTION [dbo].[SplitParameterValues] (@InputString NVARCHAR(max), @SplitChar VARCHAR(5))
RETURNS @ValuesList TABLE
param NVARCHAR(255)
AS
BEGIN
DECLARE @ListValue NVARCHAR(max)
SET @InputString = @InputString + @SplitChar
WHILE @InputString!= @SplitChar
BEGIN
SELECT @ListValue = SUBSTRING(@InputString , 1, (CHARINDEX(@SplitChar, @InputString)-1))
IF (CHARINDEX(@SplitChar, @InputString) + len(@SplitChar))>(LEN(@InputString))
BEGIN
SET @InputString=@SplitChar
END
ELSE
BEGIN
SELECT @InputString = SUBSTRING(@InputString, (CHARINDEX(@SplitChar, @InputString) + len(@SplitChar)) , LEN(@InputString)-(CHARINDEX(@SplitChar, @InputString)+ len(@SplitChar)-1) )
END
INSERT INTO @ValuesList VALUES( @ListValue)
END
RETURN
END
Use the query below create a stored procedure to return all available values for Account parameter:
create PROCEDURE sp (@keyword nvarchar(50))
AS
SELECT AccountDescription
FROM DimAccount d
inner join (SELECT [param] FROM SplitParameterValues (@keyword,',')) s on d.AccountDescription like (s.[param]+'%')
In Report Designer, select Stored Procedure as the Query type for DataSet1, then select or type sp in the drop-down list as below:
By default, there is a parameter named keyword in the Parameters pane.
Add a multi-value parameter named Account in the report, then select “Get values from a query” option for Available Values as below:
Report Design and Report Preview surface
Report Design:
Report Preview:
References:
Create User-defined Functions (Database Engine)
Adding Cascading Parameters (SSRS)
Applies to
Reporting Services 2005
Reporting Services 2008
Reporting Services 2008 R2
Reporting Services 2012
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.Hmmm. This didn't work. I even re-booted, and Firefox still doesn't show the search engine.
It was actually an update to an earlier engine, and I foolishly removed the old version rather than just updating it.
Is there anything elsewhere (eg. the registry) that might be preventing this? -
PROBLEM: The function help file contains documentation for using GPCTR_Read_Buffer with 7 parmeters in the parameter list. The NADAQ.H Header file contains 8 parameters in the function declaration. Which is right? What is the correct parameter list and can an example be provided that shows how to use the function correctly? I am currently using DAQ ver 6.92 and a 6602 Counter Timer board in a buffered start/stop or ND_BUFFERED_TWO_SIGNAL_EDGE_SEPARATION_MSR application.
Thanks for the response Filipe, I'll let you know how it goes. I only went into the header file because example code provided by NI ... paste ...
iStatus = GPCTR_Read_Buffer(iDevice, ulGpctrNum, ND_READ_MARK, ulReadOffset, ulNumPtsToRead, ulTimeOut, &ulNumPtsRead, pulReadBuf);
showed use of 8 parameters - in agreement with the header file and in disagreement with the on-line help file function documentation.
Tom -
How and where should I create a parameter list
Hi, I4m trying to create a parameter lists but I don4t know where and how.
I guess as a program unit but as function or procedure, sorry I4m new on this for that I4m finding this a bit difficult. Please, someone could help me to understand this:
PROCEDURE Run_Emp_Report IS
pl_id ParamList;
BEGIN
** Check to see if the 'tmpdata' parameter list exists.
pl_id := Get_Parameter_List('tmpdata');
** If it does, then delete it.
IF NOT Id_Null(pl_id) THEN
Destroy_Parameter_List( pl_id );
END IF;
** Create the 'tmpdata' parameter list afresh.
pl_id := Create_Parameter_List('tmpdata');
** Add a data parameter to this parameter list that will
** establish the relationship between the named query
** 'EMP_QUERY' in the report, and the record group named
** 'EMP_RECS' in the form.
Add_Parameter(pl_id,'EMP_QUERY',DATA_PARAMETER,'EMP_RECS');
**Pass a Parameter into PARAMFORM so that a parameter dialog
will not appear
**for the parameters being passing in.
Add_Parameter(pl_id, 'PARAMFORM', TEXT_PARAMETER, 'NO');
** Run the report synchronously, passing the parameter list
Run_Product(REPORTS, 'empreport', SYNCHRONOUS, RUNTIME,
FILESYSTEM, pl_id, NULL);
END;Hi,
What you've pasted the code here is absolutely correct.
You'll have to write the code in Forms builder.
You can either paste the same code in a procedure & call that procedure
from button's When-Button-Pressed trigger or paste the code in
your button's When-Button-Pressed trigger like this :
DECLARE
pl_id ParamList;
BEGIN
** Check to see if the 'tmpdata' parameter list exists.
pl_id := Get_Parameter_List('tmpdata');
Run_Product(REPORTS, 'empreport', SYNCHRONOUS, RUNTIME,
FILESYSTEM, pl_id, NULL);
END;
However, don't write the code in a function as you will need to return some value from the function.
Thanks,
Mayur Shah
[email protected] -
List all parameter in a parameter list
Hi all,
My form have a Parameter List which will have different number of parameters added to it based on different situations.
The parameter list will then pass to a procedure, does anyone know How to list out all the parameters from the parameter list
I mean, as the parameter name, parameter value & the number of parameter are changed in runtime, that's y I don't know how to show all the parameters from the list.
Thanks!How about adding one more parameter that contains indicators for each parameter you have added to the list? A simple text field might work with zeros and ones where ones correspond to parameters that are present and zeros for those not present. Or maybe a comma separated list of abbreviated indicators, but that would be more difficult to parse.
Maybe you are looking for
-
What's the impact of rowid materialized view in oracle 10g
Hello to all ; Oracle official docs saying ROWID materialized views should be used only for materialized views based on master tables from an Oracle7 database, and should not be used from Oracle8 or higher. For 10g or higher versions can we conside
-
File download is getting error while using popup
Hi experts, Working in jdev 11.1.1.3.0, ADF BC with rich faces. I am downloading word document from ADF application, i am using fileDownloadActionListener it's working fine, but before opening any file if i invoke any popup, like in my case i have to
-
My phone was working fine this A.M. and while I was on FB page it went black. I have tried turning it on and re-boot and nothing, just a black screen. Can you help me. The nearest Apple store is 2.5 hours away. Thank you
-
FF4, drag 2nd tab to new window. 2. top dragbar is off screen at top. I unmaximize the original screen, now that one also pushes the drag bar to the top off the screen. I resize the bottom of the screen and I can see a sliver of the top dragbar. If I
-
Hi, i am trying to use an xsd with maxoccurs for a rule. The rule author converts this into a LIST. If i start now a BPEL process and assign the variables, the rules work on all items which are not LIST items. Is there a trick to use them in the rule