LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Tags used in this thread
Popular LQ Tags , , ,

Reply
 
Thread Tools
Old 10-29-2009, 08:53 AM   #1
awp2513
LQ Newbie
 
Registered: Oct 2009
Posts: 4
Thanked: 0
Cannot mount a Samba share using Java's Runtime().exec()


[Log in to get rid of this advertisement]
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
windows_xp_2003 awp2513 is offline  
Tag This Post , , ,
Reply With Quote
Old 10-30-2009, 12:54 AM   #2
dragonnefyre
LQ Newbie
 
Registered: Aug 2006
Distribution: Slackware13.0-x86_64, Slackware 12.2
Posts: 12
Thanked: 0
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.
dragonnefyre is offline     Reply With Quote
Old 10-30-2009, 08:43 AM   #3
awp2513
LQ Newbie
 
Registered: Oct 2009
Posts: 4
Thanked: 0

Original Poster
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!
windows_xp_2003 awp2513 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
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
can't mount samba share and then write to the share calbazon Linux - Software 6 01-27-2004 12:52 PM
Samba printer share causes runtime errors in WinXP fearofcarpet Linux - Software 0 12-16-2003 07:57 PM


All times are GMT -5. The time now is 09:44 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration