Cannot mount a Samba share using Java's Runtime().exec()
Hello,
I have a Java program that must be used to mount a Windows share using Samba. However, when I try to mount a shared folder like this:
String command = "mount -n -t smbfs -o guest //Host/Share/ /mnt/Host/Share";
Runtime.getRuntime().exec(command).waitFor();
I get the error "SMB connection Failed"
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.
Thanks in advance
|