[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Listing current devices on Linux box

Posted on 2006-05-31
10
Medium Priority
?
198 Views
Last Modified: 2010-03-31
I write a Java program that lists all devices available on a Linux box. Such devices are floppy, cdrom, memory stick (usb) etc. I don't have root privileges. Can I do that ? Are there any sample codes out there ? Any suggestions ?

Thanks.
0
Comment
Question by:kevinnguyen
8 Comments
 
LVL 92

Accepted Solution

by:
objects earned 136 total points
ID: 16803742
without native code the best u can probably do is this

http://javaalmanac.com/egs/java.io/Roots.html
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 132 total points
ID: 16804922
Or you can use the Java communications API, I guess.
0
 
LVL 24

Assisted Solution

by:sciuriware
sciuriware earned 132 total points
ID: 16804979
You can catch the output from the mount command.

;JOOP!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 24

Expert Comment

by:sciuriware
ID: 16804984
objects, that will give you only    /     on UNIX.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16804987
You can also read a file like /etc/fstab, but to find actual mounts, use mount as I said.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 17000079
I believe I gave the only right answers:

"http://javaalmanac.com/egs/java.io/Roots.html"                         is definitively wrong,

"Or you can use the Java communications API, I guess."                is indeed a guess.


;JOOP!
0
 
LVL 35

Expert Comment

by:girionis
ID: 17000105
I am not only suggesting solutions based on answers, several times I need to do it based on guesses (i.e. to guess if a comment would lead to a possible solution) if the user does not respond back with feedback. I believe all are valid comments:

objects' is, since in Unix everything is a file and you could find devices from the file system. The user said that (s)he is using Linux so AFAIK it is a valid answer.
mayankeagle's also since you could use the java comm api to find all devices in a linux box.
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 17000981
I insist:
"http://javaalmanac.com/egs/java.io/Roots.html"  finds disk partition root directories.

On MSWindows this could be interesting (A:, C:, D:, E:, G:, K: ...)
On LINUX you get  "/"  and that's all; that's no use!

Even looking at mounted or mountable devices, as I suggested, is an incomplete solution.
If effect, only descending /dev would reveal all devices, but, only if you know the 'local implementation standards'.
I can live with guesses.
I politely suggest: split between mayankeagle and me and assign B level.

;JOOP!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question