Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux 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!


  Search this Thread
Old 10-29-2009, 08:53 AM   #1
LQ Newbie
Registered: Oct 2009
Posts: 4

Rep: Reputation: 0
Cannot mount a Samba share using Java's Runtime().exec()


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";

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
Old 10-30-2009, 12:54 AM   #2
LQ Newbie
Registered: Aug 2006
Distribution: Slackware 14.1
Posts: 20

Rep: Reputation: 2

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.
Old 10-30-2009, 08:43 AM   #3
LQ Newbie
Registered: Oct 2009
Posts: 4

Original Poster
Rep: Reputation: 0
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.



exec, java, mount, samba

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
can't mount samba share and then write to the share calbazon Linux - Software 8 10-10-2010 02:35 AM
Runtime.getRuntime().exec() Sunday03 Linux - Newbie 1 03-05-2009 06:51 AM
mount windows share export to samba share -> improve network performance tuning newuser77 Linux - Server 1 07-23-2008 12:28 PM
show the samba share but can't mount the share badall Linux - Server 3 05-30-2007 05:24 AM
Samba printer share causes runtime errors in WinXP fearofcarpet Linux - Software 0 12-16-2003 07:57 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:19 PM.

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