I want to run some unix commands inside java code. open up an ftp session and then pass username and password and change it to a particular directory. put files in there and quit the ftp session Does any of you know how to do this ftp
Bhasker Reddy
Bhasker Reddy
Ranch Hand
Joined: Jun 13, 2000
Posts: 176
posted
0
Can we do this using Runtime class process p = Runtime.getRuntime().exec(command); command can be unix commands like ftp xxx.xxx.xxx.com, username, password, cd to directory put file quit
Bhasker Reddy
Ranch Hand
Joined: Jun 13, 2000
Posts: 176
posted
0
Process p = Runtime.getRuntime().exec("ftp"); Process p1 = Runtime.getRuntime().exec("open servername.xxx.xxx.com"); Process p2 = Runtime.getRuntime().exec("USERNAME"); Process p3 = Runtime.getRuntime().exec("PASSWORD"); Process p4 = Runtime.getRuntime().exec("cd ../../oraexp/ORACLE/xxxx/export/XML/"); Process p5 = Runtime.getRuntime().exec("put 23005.xml"); Process p6 = Runtime.getRuntime().exec("quit"); Process p7 = Runtime.getRuntime().exec("quit"); I tried to Run these, but i am getting errors I am on a windows 2000 box, and i am trying to ftp to a oracle unix server.
Guy Allard
Ranch Hand
Joined: Nov 24, 2000
Posts: 776
posted
0
Can you run the ftp from a Win2K command line? Make sure that works first. Then be a little more specific on 'errors' please. Regards, Guy
Eric lau
Greenhorn
Joined: Jan 21, 2002
Posts: 27
posted
0
I try the exec() but i get error = num where can I get the description of the error with the num?
Originally posted by Bhasker Reddy: Process p = Runtime.getRuntime().exec("ftp"); Process p1 = Runtime.getRuntime().exec("open servername.xxx.xxx.com"); Process p2 = Runtime.getRuntime().exec("USERNAME"); Process p3 = Runtime.getRuntime().exec("PASSWORD"); Process p4 = Runtime.getRuntime().exec("cd ../../oraexp/ORACLE/xxxx/export/XML/"); Process p5 = Runtime.getRuntime().exec("put 23005.xml"); Process p6 = Runtime.getRuntime().exec("quit"); Process p7 = Runtime.getRuntime().exec("quit"); I tried to Run these, but i am getting errors I am on a windows 2000 box, and i am trying to ftp to a oracle unix server.
What is 'num'? And by exact error, if there is a stack trace, please provide it.
Eric lau
Greenhorn
Joined: Jan 21, 2002
Posts: 27
posted
0
such as what is the means of error=2 and where can I get all description of the error code? java.io.IOException: CreateProcess: guest error=2 at java.lang.Win32Process.create(Native Method) at java.lang.Win32Process.<init>(Win32Process.java:64) at java.lang.Runtime.execInternal(Native Method) at java.lang.Runtime.exec(Runtime.java:272) at java.lang.Runtime.exec(Runtime.java:195) at java.lang.Runtime.exec(Runtime.java:152) at testThread.Untitled1.main(Untitled1.java:89)
Originally posted by Mike Curwen: yes, you can ftp from Windows command line.
What is 'num'? And by exact error, if there is a stack trace, please provide it.
Originally posted by Bhasker Reddy: Can we do this using Runtime class process p = Runtime.getRuntime().exec(command); command can be unix commands like ftp xxx.xxx.xxx.com, username, password, cd to directory put file quit
you should be doing something like this. InputStream ip = p.getInputStream(); and write the ftp commands to the stream
Bhasker Reddy
Ranch Hand
Joined: Jun 13, 2000
Posts: 176
posted
0
Do you mean to say that i need to write ftp commands in input stream and put the input stream in the Runtime.exec(inputstream). can you be more specific
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.