Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Executing a program with exec perl

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 08-03-2010
Member
 
Join Date: Dec 2009
Posts: 204
Executing a program with exec perl
  

Hello,
I'm enthusiasm to develop an application that will be a web portal where you can launch different tools are perl programs. I read a lot of docs on the runtime class and function exec. My problem is that when I run the perl script from the command line it runs perfectly well but it takes a few seconds. When I run my java application, it runs the program as perl, but it looks like it stops in the middle, because in my view of the output variable I is the first line of the program output. It does not display the lines that appear after a few seconds. I do not have any idea about what exactly is happening with the code. If you have any idea then please let me know. Thanks in advance.

Reply With Quote
  #2  
Old 08-03-2010
Member
 
Join Date: Nov 2009
Posts: 343
Re: Executing a program with exec perl

Hello,
Some tips on what you are looking for
- You throw your thread after reading waitfor ()And therefore after the end of your perl script. If he writes too much data in its standard output or errors you may find yourself in a situation of deadlock (the 2 programs expect each other). must perform the treatments on stream I / O just after launching the program, and before waitfor ().
- You do not read the error stream ... Gold is generally where to find a possible error message. Also, if you do not treat a streams (stdin, stdout or stderr), I strongly advise you to close.
Hope this will help you.
Reply With Quote
  #3  
Old 08-03-2010
Member
 
Join Date: Nov 2009
Posts: 583
Re: Executing a program with exec perl

Hello,
I agree with the above post and I would like to add some more points to it
- You use concat () to concatenate strings, which may be a gulf in terms of memory usage and performance. Prefer him StringBuffer see StringBuilder (equivalent non-synchronized).
- You have a timing issue on the variable "exit" because you read it right after having started the thread that should inform the ... there is a good chance it is still empty .
- Your code is not portable (I do not know if it is a necessity for you) because I do not think it is possible to launch a perl script in this way under Windows ...
Reply With Quote
  #4  
Old 08-03-2010
Member
 
Join Date: Dec 2009
Posts: 178
Re: Executing a program with exec perl

Hello,
I think I have a similar kind of a problem with me. My perl script generates a folder with multiple files, I create this directory defaults to the root of my home. I want him put in a folder that I created previously. I try with this command just before the start of the perl script, for it is located in the folder. But no result, it makes me even rep qd result to the root. If you have any solution for this then please help me and post back the solution. Thanks in advance.
Reply With Quote
  #5  
Old 08-03-2010
Member
 
Join Date: Nov 2009
Posts: 518
Re: Executing a program with exec perl

Hello,
To close the inflow of your process you should do something like this
Code:
process.getInputStream().close()
I think you should take a look at the basics of the perl programming language and then start with the coding part and if you are using java with the perl language then you should see the java native function that is this feature lets you import a different language's method or function in the java program and you can even execute that method through the java virtual machine.
Reply With Quote
  #6  
Old 08-03-2010
Member
 
Join Date: Nov 2009
Posts: 335
Re: Executing a program with exec perl

Hello,
This is normal since the two controls are completely independent of each other. It is better to use the method exec () which takes the execution path as a parameter. But it must specify the full path to the perl script in this case, unless it is in the PATH. In Java standard input (stdin in C) is available via the System.in field. I was talking about the flow process started, which are reversed when used from the Java program. They are accessible via the method getOutputStream (), getInputStream () and getErrorStream () Class Process. Hope this information will help you.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Executing a program with exec perl"
Thread Thread Starter Forum Replies Last Post
Compiling and Executing a Python program. Blake's Software Development 3 15-02-2012 04:46 PM
Program Structure in Perl Iker Software Development 5 27-01-2011 04:22 PM
Not able to see HDAPM program executing Brandon67 Portable Devices 4 24-05-2010 02:38 PM
Executing java program via a script Jensen Ackles Software Development 5 29-03-2010 12:47 PM
Modification of an existing program in Perl AdityaR Software Development 3 26-11-2009 06:02 PM


All times are GMT +5.5. The time now is 09:52 PM.