LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: 0
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
 
Old 10-29-2009, 11:54 PM   #2
dragonnefyre
LQ Newbie
 
Registered: Aug 2006
Distribution: Slackware 14.2
Posts: 20

Rep: Reputation: 2
Hi,

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, 07:43 AM   #3
awp2513
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.

Thanks!
 
  


Reply

Tags
exec, java, mount, samba



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:43 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