wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes problem in RunTime.exec Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "problem in RunTime.exec" Watch "problem in RunTime.exec" New topic
Author

problem in RunTime.exec

gudla Dathathreya Reddy
Greenhorn

Joined: May 05, 2004
Posts: 15
Hi friends,
I am getting a problem in my application. I will state the complete problem in detail. I have to transfer 3 files from one NT machine to unix machine some where kept in net work, I used an ftp in 'Process p = getRunTime().exec("ftp -i -s:ftp.txt")'. In ftp.txt file I have given the necessary things for ftp to unix machine. The files are transfering into the unix box. When I to the process for the 2nd time I have to check whether the file are exists in the unix box, then only transfer the files. Now, again I am doing ftp bring the files from the unix box to NT machines using 'Process p = getRunTime().exec("ftp -i -s:ftp1.txt")' where ftp1 contains all the necessary things for ftp to unix machine . Now I am checking for the files available in the NT machine using boolean=(new File(filename)).exists(), Fine out of 3 files, 2 file shows the return type as 'true' and one file is showing 'false', even the same happens if I delete the 3 files after checking, out of 3 files, 2 file shows the return type as 'true' and one file is showing 'false'. I went to the folder where I am bring files from and removing the files manually, one file is showing share violation, one process is using the file . I am unable to resolve this problem, will this code what I write is acceptable if not suggest any other code. I have sending all the snippets of the programs. I am doing this in the development environment like this. My production environment is totally both are unix machines.

1. ftp to transfer files.(tranfer.txt)called in java code down

open 172.16.30.6
informix
informix
bin
has
cd /tmp
put d:/dathu/CSV/bssfa932.txt
put d:/dathu/CSV/bssfa933.txt
put d:/dathu/CSV/bssfa936.txt
bye

2. ftp to get the files(get.txt)used in java code down

open 172.16.30.6
informix
informix
bin
has
cd /tmp
lcd d:/dathu/hold
get bssfa932.txt
get bssfa933.txt
get bssfa936.txt
bye

3. java code snippet to getfiles
Process p = Runtime.getRuntime().exec("ftp -i -s:get.txt");

4. java code to check the files exist

boolean filestatus=moCreatFlatFilerobj.isFileExists();

public boolean isFileExists(){
boolean isfileexisting=false;
boolean blnordhead = (new File(file1 with path)).exists();
boolean blnordlines = (new File(file2 with path)).exists();
boolean blnaccount = (new File(file3 with path)).exists();
if(blnordhead && blnordlines && blnaccount){
isfileexisting=true;
return isfileexisting;
}

5. java code to delete files

public void deleteFiles(){
boolean header= (new File(file1 with path)).delete();
boolean line =(new File(file2 with path)).delete();
boolean account=(new File(file3 with path)).delete();
}

6. java code to tranfer files.
p = Runtime.getRuntime().exec("ftp -i -s:transfer.txt");

Please help me...
My email dathathreyareddy@yahoo.co.in
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in RunTime.exec
 
Similar Threads
nio and getRuntime()?
I/O Question.
Runtime .getRuntime(). exec(cmd)
getRuntime().exec() - HELP PLEASE
getRuntime question