Results 1 to 6 of 6

Thread: Executing a program with exec perl

  1. #1
    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.

  2. #2
    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.

  3. #3
    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 ...

  4. #4
    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.

  5. #5
    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.

  6. #6
    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,517,160.54936 seconds with 16 queries