Results 1 to 2 of 2
- 07-19-2011, 09:57 PM #1
Member
- Join Date
- May 2011
- Posts
- 9
- Rep Power
- 0
Thread: How to execute unix commands through Windows/cygwin using Java
I am trying to accomplish two things:
1. I am running cygwin on Windows7 to execute my unix shell commands and I need to automate the process by writing a Java app. I already know how to use the windows shell through Java using the 'Process class' and 'Runtime.getRuntime().exec(cmd /c dir)'. I need to be able to do the same with unix commands: i.e.: 'ls -la' and so forth. What should I look into ?
I have tried running 'Runtime.getRuntime().exec("C:\\cygwin\\bin
mintty.exe -e ls -la")' or 'Runtime.getRuntime().exec("C:\\cygwin\\bin
bash.exe -c ls -la");', but for some reason, both mintty and bash end up not recognizing basic commands like the 'ls' when they are called this way !?
2. Is there a way to remember a shell's state? explanation: when I use: 'Runtime.getRuntime().exec(cmd /c dir)' I always get a listing of my home directory. if I do 'Runtime.getRuntime().exec(cmd /c cd )' and then do 'Runtime.getRuntime().exec(cmd /c dir)' again, I will still get the listing of my home folder. Is there a way to tell the process to remember its state, like a regular shell would?
- 07-20-2011, 04:40 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
Similar Threads
-
Running commands in cygwin(aspell) through java
By nikhidas in forum Advanced JavaReplies: 0Last Post: 06-22-2011, 08:24 PM -
Execute Cygwin command from Java app
By ZebraIzToronto in forum Advanced JavaReplies: 1Last Post: 01-21-2011, 05:51 AM -
Run Unix commands from Java
By yahyaaa in forum New To JavaReplies: 13Last Post: 06-17-2010, 11:50 PM -
Need Help to Execute the commands from Java Program
By Anjaneyulu in forum Advanced JavaReplies: 7Last Post: 02-24-2010, 02:35 PM -
how to run java app on windows in a cron like on unix
By rockie12 in forum Advanced JavaReplies: 7Last Post: 05-23-2008, 01:39 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks