LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-20-2011, 03:26 AM   #1
riyas_ppt
LQ Newbie
 
Registered: Dec 2011
Posts: 1

Rep: Reputation: Disabled
Executing df -k command from java is not working for multiple execute


Hi,

I am executing df -k command from java using below code snippet.

Process proc = Runtime.getRuntime().exec("df -k " + path );

Its working fine when i execute only once. At the same if i execute for multiple times its failed. proc.exitValue is returning 1.

Could anyone please let me know if i need to do anything more here.

Regards,
Riyaz
 
Old 01-13-2012, 10:20 AM   #2
hyperdaz
Member
 
Registered: Sep 2004
Location: UK
Distribution: CentOS 5.5
Posts: 44

Rep: Reputation: 1
depending on the distro..

do
which df

on the command line should give you the full path to df.

ie.
CentOS
/bin/df

Then add your full path to your java command.

Process proc = Runtime.getRuntime().exec("/bin/df -k /root" );

ideally your java code should check which distro / OS it is running agenst and add the correct location of df, uname -a is your friend for this.

Last edited by hyperdaz; 01-13-2012 at 10:23 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
executing shell command from java melih utkan Programming 2 05-10-2009 09:36 AM
script to execute a command multiple times snr8fl3 Programming 5 11-17-2008 12:49 PM
Execute a linux command using a java program tvalenzuela Programming 2 10-07-2005 11:59 AM
Problem executing this piped command: JAVA randomx Programming 1 07-16-2004 07:39 PM
Newbie question about executing java command oldoldcat Linux - General 4 01-30-2004 01:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration