LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-24-2008, 09:59 AM   #1
snowman81
Member
 
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 282

Rep: Reputation: 30
Problems with script to mount network share


So I have to write a simple script that mounts a network share. I already did one in VBscript for windows and applescript for OS X so I figured it would be a piece of cake for Linux cause it is my strongest area. Nope, every time I run the code I get this error
Code:
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
Here is the script
Code:
#!/bin/bash

echo "What is your username?"
read $var1

echo "What is your password?"
read $var2



sudo mount -t cifs //macx/swu /home/jason/Desktop/mine -o user=$var1,password=$var2
I eventually have to make the prompts into a graphical box but I'll deal with that when I get this figured out.
 
Old 04-25-2008, 09:30 PM   #2
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
I don't know the reason behind your problem, but I recall coming across it myself and solving it by using a different authentication method - e.g.:-
Code:
echo "username=$var1" > /tmp/cred.txt
chmod 600 /tmp/cred.txt
echo "password=$var2" >> /tmp/cred.txt
sudo mount -t cifs //macx/swu /home/jason/Desktop/mine -o credentials=/tmp/cred.txt
rm -f /tmp/cred.txt
 
Old 04-25-2008, 09:58 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I also would recommend a credentials file located in your home directory that only you can read. Then use the "cred=/full/path/to/.credentials" option in the script.

Having passwords in /etc/fstab or scripts is a bad idea, especially if the script is world readable.
I think that an entry in /etc/fstab would be a better idea than a mount command in a script. Then "sudo mount //macx/swu" will be able to mount the directory.

An entry in /etc/fstab for this share using the "_netdev" option and without the "noauto" option will allow this share to be mounted when you boot up. Then you don't need your script or even to enter in a command.

Does Mac OS X support the cifs filesystem? If not, you may need to use "smbfs" as the filesystem instead. In this case, you could try the "users" fstab entry option. Together with the "uid=" & "gid=" options, this may allow you to run the mount command as a regular user.

Also, verify that your credentials are correct.

Last edited by jschiwal; 04-25-2008 at 10:00 PM.
 
  


Reply


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
Script to mount a share zmsc1 Linux - Software 3 09-05-2007 07:59 AM
Unable to mount NFS share through network IP hot_wired13 Linux - Server 1 09-02-2007 07:29 PM
problems with script writing to network share neocookie Linux - Newbie 2 03-22-2007 05:44 AM
Cannot mount an NT network share pharpe Linux - Networking 3 04-29-2002 07:58 AM
Mount network share at startup. Ge0ph Linux - Networking 3 10-17-2001 08:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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