Active Topics

 



Notices


Reply
Thread Tools
Posts: 279 | Thanked: 95 times | Joined on Sep 2009
#81
ok thanks.
when i run cifsmount in /home/user folder i get not found error so i tried
sh /home/user/cfsmount and i now got syntax eror on line 4 . i have copied and used editplus to save it. is there any encoding type i need to use to save this script? i'm on windows
 
Posts: 692 | Thanked: 264 times | Joined on Dec 2009
#82
You need to use Unix encoding (with ANSI characters, to be safe). Notepad++ can do this, or if you make the file on your N900 it should be saved with Unix encoding. I'm 99.9% sure this script should work fine but I haven't tested it on Fremantle so I can't be totally certain.

Edit: just found a problem with the code. Working to fix.

Update: Fixed.

Last edited by GameboyRMH; 2010-01-14 at 23:37.
 
Posts: 40 | Thanked: 4 times | Joined on Mar 2008
#83
Originally Posted by GameboyRMH View Post
You need to use Unix encoding (with ANSI characters, to be safe). Notepad++ can do this, or if you make the file on your N900 it should be saved with Unix encoding. I'm 99.9% sure this script should work fine but I haven't tested it on Fremantle so I can't be totally certain.

Edit: just found a problem with the code. Working to fix.

Update: Fixed.
I tried your script but there are some problems: mind that N900 doesn't have bash but another shell (ash): so synthax is possibly different from a bash script and "#! /bin/bash" should be replaced with "#! /bin/sh".

I replaced the first line so I could run the script but I get error on line 4: "(" expected.
So I really believe synthax is not the same....

Thanks for your effort!

Last edited by famusc; 2010-01-15 at 12:25.
 
Posts: 840 | Thanked: 823 times | Joined on Nov 2009
#84
As far as I know (somebody correct me if I'm wrong) the original bourne shell does not have arrays; except one which can be changed with the "set" command. this array initially stores the command line arguments.

You get the array values with $1 $2 etc, and the size with $#
I will rewrite GameboyRMH's script for the original bourne shell (/bin/sh) and post it here then he can make the necessary changes.

I hope you don't mind GameboyRMH.

Edit: ok, I changed some of it. There are probably some syntax differences I didn't spot but see if it works with this and tell me where it complains

Code:
#! /bin/sh
#arguments: servername serverip share username password mountpoint
#username, password and mountpoint are optional arguments
if [ $# -lt 3 ] ; then
    #Go into "wizard mode" if there are no arguments
    echo -e "Not enough arguments passed - running wizard"
    echo -e "Enter the server name:"
    read servername
    echo -e "Enter the server IP"
    read serverip
    echo -e "Enter the share name or path"
    read sharename
    echo -e "Enter a username, or leave blank for anonymous"
    read username
    username_orig=$username
    if [ "${username}" != "" ]; then
        echo -e "Enter a password"
        read password
    fi
    echo -e "Enter a mount point, or leave blank for automatic"
    read mountpoint
fi
#if arguments were passed from the command line, use them:
if [ $# -gt 2 ]; then
    servername=$1
    serverip=$2
    sharename=$3
    username=$4
    username_orig=$username
    password=$5
    mountpoint=$6
fi
#set default mountpoint if the user didn't enter one
if [ "${mountpoint}" = "" ]; then
    mountpoint="/media/Remote_Filesystems/$servername@$sharename"
    #make sure the Remote_Filesystems directory exists
    mountparentdir="/media/Remote_Filesystems"
    if [ -d $mountparentdir ]; then
        echo -e "$mountparentdir found."
    else 
        echo -e "Creating $mountparentdir"
        mkdir $mountparentdir
    fi
fi
#requote variables to escape special characters
servername=$(printf '%q' "$servername")
serverip=$(printf '%q' "$serverip")
sharename=$(printf '%q' "$sharename")
username=$(printf '%q' "$username")
password=$(printf '%q' "$password")
mountpoint=$(printf '%q' "$mountpoint")
#check for mountpoint and create it if it doesn't exist
if [ -d $mountpoint ]; then
    echo -e "Mount point already exists - will attempt to use."
else 
    echo -e "Creating mountpoint $mountpoint"
    mkdir $mountpoint
fi 
echo -e "Attempting to mount //$servername/$sharename at $mountpoint"
#Run the mount command
if [ "${username_orig}" = "" ]; then
mount -t cifs //$servername/$sharename $mountpoint -o user=$username pass=$password ip=$serverip
else
mount -t cifs //$servername/$sharename $mountpoint -o ip=$serverip
fi
#chown mountpoint to user
chown -R user $mountpoint
echo -e "To unmount this share, run umount $mountpoint as root"

Last edited by Cue; 2010-01-15 at 14:27.
 

The Following 3 Users Say Thank You to Cue For This Useful Post:
Posts: 692 | Thanked: 264 times | Joined on Dec 2009
#85
Thanks Cue
 
Posts: 10 | Thanked: 1 time | Joined on Jan 2010
#86
hi nathan, this is the error message if you specify iocharset=utf8 parameter.
mount: mounting //ip/share on /mnt failed: Can not access a needed shared library
maybe you have seen the error already
 
Posts: 452 | Thanked: 522 times | Joined on Nov 2007
#87
Originally Posted by heretic View Post
hi nathan, this is the error message if you specify iocharset=utf8 parameter.
mount: mounting //ip/share on /mnt failed: Can not access a needed shared library
maybe you have seen the error already
No, I hadn't seen the error. But now that you provided it; I was able to find out why it occurs. Apparently utf8 support requires that you have the nls_utf8 module installed in the kernel. I can submit it to the buildbots probably "tomorrow" and then you can install it, and I would guess you would be good to go.

Nathan
 
Posts: 452 | Thanked: 522 times | Joined on Nov 2007
#88
Actually I decided to just do it now. I've uploaded:
kernel-module-nls-utf8
to the buliderbots. It should shortly be in the extras-devel, once you have that installed you should be able to use iocharset=utf8

Nathan
 

The Following 3 Users Say Thank You to Nathan For This Useful Post:
Posts: 692 | Thanked: 264 times | Joined on Dec 2009
#89
Just one correction to on top of Cue's modifications:

Code:
#! /bin/sh
#arguments: servername serverip share username password mountpoint
#username, password and mountpoint are optional arguments
if [ $# -lt 3 ] ; then
    #Go into "wizard mode" if there are no arguments
    echo -e "Not enough arguments passed - running wizard"
    echo -e "Enter the server name:"
    read servername
    echo -e "Enter the server IP"
    read serverip
    echo -e "Enter the share name or path"
    read sharename
    echo -e "Enter a username, or leave blank for anonymous"
    read username
    username_orig=$username
    if [ "${username}" != "" ]; then
        echo -e "Enter a password"
        read password
    fi
    echo -e "Enter a mount point, or leave blank for automatic"
    read mountpoint
fi
#if arguments were passed from the command line, use them:
if [ $# -gt 2 ]; then
    servername=$1
    serverip=$2
    sharename=$3
    username=$4
    username_orig=$username
    password=$5
    mountpoint=$6
fi
#set default mountpoint if the user didn't enter one
if [ "${mountpoint}" = "" ]; then
    mountpoint="/media/Remote_Filesystems/$servername@$sharename"
    #make sure the Remote_Filesystems directory exists
    mountparentdir="/media/Remote_Filesystems"
    if [ -d $mountparentdir ]; then
        echo -e "$mountparentdir found."
    else 
        echo -e "Creating $mountparentdir"
        mkdir $mountparentdir
    fi
fi
#requote variables to escape special characters
servername=$(printf '%q' "$servername")
serverip=$(printf '%q' "$serverip")
sharename=$(printf '%q' "$sharename")
username=$(printf '%q' "$username")
password=$(printf '%q' "$password")
mountpoint=$(printf '%q' "$mountpoint")
#check for mountpoint and create it if it doesn't exist
if [ -d $mountpoint ]; then
    echo -e "Mount point already exists - will attempt to use."
else 
    echo -e "Creating mountpoint $mountpoint"
    mkdir $mountpoint
fi 
echo -e "Attempting to mount //$servername/$sharename at $mountpoint"
#Run the mount command
if [ "${username_orig}" != "" ]; then
    mount -t cifs //$servername/$sharename $mountpoint -o user=$username pass=$password ip=$serverip
else
    mount -t cifs //$servername/$sharename $mountpoint -o ip=$serverip
fi
#chown mountpoint to user
chown -R user $mountpoint
echo -e "To unmount this share, run umount $mountpoint as root"
 

The Following User Says Thank You to GameboyRMH For This Useful Post:
oweng's Avatar
Posts: 210 | Thanked: 178 times | Joined on Jan 2010
#90
Massive knoob here!

I've copied and pasted then saved a text file to mydocs called 'cifsmount'

tried also in the parent directory

then in x terminal "chmod u+x cifsmount" fails
chmod: cifsmount: No such file or directory

Any ideas?

Also when I have typed in 'sudo gainroot'
then tried './cifsmount' and also 'cifsmount'
both fail
/bin/sh: ./cifsmount: not found
/bin/sh: ./cifsmount: not found

So I'm certain that
1. I'm clueless
2. I need help and a bigger / better brain
3. I need an even easier step by step guide

Accessing my windows shares seems like a desirable goal - very suprised smb support is missing by default

btw kernel-modules-cifs installed - have i missed anything?
thanks


Originally Posted by GameboyRMH View Post

Noob instructions:[/B] Copy contents, save it as something like say "cifsmount", then run "chmod u+x cifsmount." You need to run this script as root, so with rootsh installed run "sudo gainroot." You can then either run it in "wizard mode" by running "./cifsmount" or pass arguments to it like "./cifsmount myhomeserver 192.168.254.10 mysharedfolder myusername mypassword /mount/point" (arguments are all documented in the code comments)

Username, password and mountpoint are all optional. You must specify a username and password to use a custom mountpoint if you're doing it with arguments, but if you're connecting to an anonymous share you can put anything in those fields.

By default it uses the same mountpoints as Wizard Mounter: /media/Remote_Filesystems/servername@share. You have to unmount manually: "umount /media/Remote_Filesystems/whatever@whatever." The script will tell you exactly what at the end.
 
Reply

Tags
cifs, ntfs, samba, smb, truecrypt


 
Forum Jump


All times are GMT. The time now is 23:14.