delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/07/11/05:50:30

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3B4C22D4.B87A8DDC@acris.co.uk>
Date: Wed, 11 Jul 2001 10:56:36 +0100
From: Julian Hall <jules AT acris DOT co DOT uk>
X-Mailer: Mozilla 4.7 [en-gb] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Java Runtime.exec()

--------------A4A4F62DC3A4EC7C72C7F3D1
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

From the description of your problem, it is that you are unable to run a
shell script (ie, a file that starts '#!/....some interpreter').  This
is due to the fact that this file format is not understood by Windows,
and Cygwin has to do some interpretation of the file to make it work.
The JVM is not using the Cygwin exec functions.  There are a few
possible solutions, depending on how well you need the function to
perform.

If you know what the interpreter of your script is, you can just call
Runtime.exec("<path to interpreter> <script filename>"), which should
work.

Alternatively, If you do not know what the type of file is you could
load the first line of text out of it, and if it starts #! translate the
rest of the first line to a windows filename (in most cases just
prepending the path to the cygwin root directory should suffice) and
exec that.

A third option, if you want to spend the time on it, would be to write a
CygwinRuntime java class (or similar) that interfaced directly to the
cygwin library.  This could include functions for translating filenames,
executing programs, etc, and would be a generally useful class to have
around.

Jules



--------------A4A4F62DC3A4EC7C72C7F3D1
Content-Type: message/rfc822;
 name="cygwin.32651"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cygwin.32651"

Message-ID: <2F5BD88EB480D3119E35009027AF99B50174A13D AT xpa03 DOT corp DOT hp DOT com>
From: "SAWANT,SACHIN (Non-HP-PaloAlto,ex1)" <sachin_sawant AT non DOT hp DOT com>
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: Java Runtime.exec()
Date: Mon, 9 Jul 2001 18:03:02 -0700 
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"

Hi,

We are using cygwin to run our application. I am trying to execute a shell
file at the operation system through java. The code is as follows 


     String unixCommand = "./run.sh";
     Runtime rt = Runtime.getRuntime(); 
     Process proc = rt.exec("unixCommand"); 

     InputStream result = proc.getInputStream(); 
     InputStreamReader isr = new InputStreamReader(result); 
     BufferedReader br = new BufferedReader(isr); 
     String line = null; 
       
     while ( (line = br.readLine()) != null) 
             out.println(line); 
       
     int exitVal = proc.waitFor(); 


  I am getting CreateProcess Exception when I try to run this code. It does
work well for other unix commands like "ls" or "ps". Am I doing something
wrong?


Regards

Sachin 


--------------A4A4F62DC3A4EC7C72C7F3D1
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--------------A4A4F62DC3A4EC7C72C7F3D1--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019