problem in executing unix script from java

R

ruds

hello,
I want to find out how much free disk space is present for a particular
directory in unix system.
For this I'm executing command :
p=r.getRuntime().exec("rsh "+machine+" \"cd /scratch; df -k .\" |
awk '{print $3}' ");

but, the '-' sign of df -k and the single quotes for print do not get
exceuted and hence I'm not able to get a proper o/p.

can anyone tell me how to execute it?
 
G

Gordon Beaton

For this I'm executing command :
p=r.getRuntime().exec("rsh "+machine+" \"cd /scratch; df -k .\" |
awk '{print $3}' ");

but, the '-' sign of df -k and the single quotes for print do not
get exceuted and hence I'm not able to get a proper o/p.

can anyone tell me how to execute it?


Try it like this instead, using an array to group the command
arguments properly:

String[] cmd = { "rsh",
machine,
"cd /scratch; df -k . | awk '{print $3}'"
};


p = r.getRuntime.exec(cmd);

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top