Anam Ghouri

Greenhorn
+ Follow
since Oct 24, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anam Ghouri

Here is the code for someone who needs it:

12 years ago
Hi,

I need to connect to Linux using java code from my Windows machine and execute a linux command. Following is the code I am using:



I am getting following error while executing this code:

java.io.IOException: Cannot run program "grep": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at macys.RunCommand.main(RunCommand.java:45)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 5 more
exception happened - here's what I know:


I think it is not executing linux command because it is still in Windows operating system. When I include the following code in my program, i can see that is still in Windows.


Output: "I am windows"

I need to connect to Linux and execute a Linux command from Windows. How do I do it using Java code? Can somebody please help me out in this asap?
12 years ago