Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

problem in executing unix script from java

Thread view: 
ruds - 27 Dec 2006 11:29 GMT
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[i]+" \"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?
Gordon Beaton - 27 Dec 2006 13:37 GMT
> For this I'm executing command :
> p=r.getRuntime().exec("rsh "+machine[i]+" \"cd /scratch; df -k .\" |
[quoted text clipped - 4 lines]
>
> 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[i],
                   "cd /scratch; df -k . | awk '{print $3}'"
                };

 p = r.getRuntime.exec(cmd);

/gordon

Signature

[ don't email me support questions or followups ]
g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e

ruds - 29 Dec 2006 05:27 GMT
Thanks, It did help me.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.