Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > calling a bash script but cannot get out

Reply
Thread Tools

calling a bash script but cannot get out

 
 
charly
Guest
Posts: n/a
 
      12-07-2003
Hi !

I'm working on a website which can generate a dump of a database. I
generate csv files then tar and zip them and redirect the browser to the
file.

The problem is that I cannot get out of the process I create :

String dest ="/bin/tar -cz " + SaveDir + "*.csv -f " + SaveDir + nomZip
+ " & exit";
String[] commande = { "/bin/bash", "-c", dest };

System.out.println(" Saving...);
Process process = Runtime.getRuntime().exec(commande);

/*BufferedReader inputreader =
new BufferedReader(
new InputStreamReader(process.getInputStream()));
BufferedReader errorreader =
new BufferedReader(
new InputStreamReader(process.getErrorStream()));
String readerdata;

while ((readerdata = inputreader.readLine()) != null) {
System.out.println("On stdout: " + readerdata);
}
while ((readerdata = errorreader.readLine()) != null) {
System.out.println("On stderr: " + readerdata);
}*/

But Tomcat tells me : process hasn't exited

But I issued a exit command so what's happening ?

Hope to get some help from you folks

 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      12-07-2003
charly wrote:
> Hi !
>
> I'm working on a website which can generate a dump of a database. I
> generate csv files then tar and zip them and redirect the browser to the
> file.
>
> The problem is that I cannot get out of the process I create :
>
> String dest ="/bin/tar -cz " + SaveDir + "*.csv -f " + SaveDir + nomZip
> + " & exit";

^^^^^^^
Get rid of the superfluous stuff. It's not even the correct syntax!

 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      12-07-2003
Sudsy wrote:
> charly wrote:
>
>> Hi !
>>
>> I'm working on a website which can generate a dump of a database. I
>> generate csv files then tar and zip them and redirect the browser to
>> the file.
>>
>> The problem is that I cannot get out of the process I create :
>>
>> String dest ="/bin/tar -cz " + SaveDir + "*.csv -f " + SaveDir +
>> nomZip + " & exit";

>
> ^^^^^^^
> Get rid of the superfluous stuff. It's not even the correct syntax!
>



Sorry...my newsreader morphed my reply. Get rid of the " & exit" at the
end of your command. I'd also change the command to read as follows:
String dest = "/bin/tar cfz " + saveDir + nomZip + " " + saveDir + "*.csv";

 
Reply With Quote
 
charly
Guest
Posts: n/a
 
      12-07-2003
Thank you !

In fact, the exit was useless and I should have thought a little harder
before posting :

I just had to to this :
Process process = Runtime.getRuntime().exec(commande);
process.waitFor(); -> It's a new thread : I've got to wait for him in
this case

thank you for your input though

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a bash script creates files as UID 501 ? Dreamcat Four Ruby 9 11-19-2010 10:36 AM
Re: Terminate a python script from linux shell / bash script norseman Python 0 07-10-2008 09:44 PM
RE: Terminate a python script from linux shell / bash script Gros Bedo Python 1 07-10-2008 08:50 PM
Terminate a python script from linux shell / bash script Gros Bedo Python 2 07-10-2008 08:42 AM
(patch for Bash) GTK+2 + Bash William Park XML 3 07-14-2005 12:09 AM



Advertisments