Cannot mount a Samba share using Java's Runtime().exec()
Linux - NewbieThis forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have tried the exec command both with and without .waitFor() and "sudo mount..."
The command itself works when I enter it on the command line or if I run the command in a bash script.
So why don't I just do those methods? Well, there are several reasons. The most important is that this is being added to existing code and it must take this particular form.
I don't see why this shouldn't work, but then again, I'm new at this. No documentation I've come across has hinted at all as to why this won't work. This may be a "java question" and not a "Linux" one, but I was hoping somebody had fought with this before and knows the answer or where to find it.
if it works on the command line or a shell then it looks more like a java problem. I don't know much about java. Are "host" and "share" variables set earlier or are they hard coded? If they are set elsewhere maybe you could hardcode the values and see if that works. Perhaps you could add a line that echoes the value of string command? I guess you may have done it already, just thought I should mention it.
Yes, /Host/Share is a placeholder for a string in my code. I have verified that the command is correct (by entering it on the command line) and that when the method containing this code is called that the string has the value I expect.
From what I've read, there a few different flavors of exec (take different arguments). It may be that it is parsing my input incorrectly without me knowing it, and using the exec(string[],...) version may solve the issue. I'm not sure though.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.