|
|
2010-01-18
, 17:37
|
|
Posts: 20 |
Thanked: 1 time |
Joined on Jan 2010
@ The Netherlands
|
#111
|
|
|
2010-01-18
, 17:43
|
|
|
Posts: 850 |
Thanked: 626 times |
Joined on Sep 2009
@ Vienna, Austria
|
#112
|
I'm trying to reproduce this, but don't succeed (N900/2.2009.51-1). If I do (as root) 'mkdir /media/qqq', I don't see the directory 'qqq' with the built-in File Manager, even if I do 'chown -R user /media/qqq'. How come?
| The Following User Says Thank You to SubCore For This Useful Post: | ||
|
|
2010-01-18
, 17:59
|
|
Posts: 20 |
Thanked: 1 time |
Joined on Jan 2010
@ The Netherlands
|
#113
|
|
|
2010-01-18
, 18:44
|
|
|
Moderator |
Posts: 7,109 |
Thanked: 8,820 times |
Joined on Oct 2007
@ Vancouver, BC, Canada
|
#114
|
|
|
2010-01-18
, 18:51
|
|
Posts: 1 |
Thanked: 1 time |
Joined on Jan 2010
|
#115
|
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"
#! /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 edivad75 For This Useful Post: | ||
|
|
2010-01-18
, 21:32
|
|
Posts: 20 |
Thanked: 1 time |
Joined on Jan 2010
@ The Netherlands
|
#116
|
|
|
2010-01-19
, 01:15
|
|
Posts: 840 |
Thanked: 823 times |
Joined on Nov 2009
|
#117
|
i have comment the requote of vaiables and i have separate the parameter in mount command after "-o" with comma "," and not with space " "
i have put the script with exenshions ".sh" in the bin directory and i have run "chmod u+x cifsmount.sh" with root privileges.
i have execute the script with root privileges
Sorry for my little english and thanks a lot at All!
edivad
|
|
2010-01-19
, 06:32
|
|
Posts: 452 |
Thanked: 522 times |
Joined on Nov 2007
|
#118
|
|
|
2010-01-19
, 13:46
|
|
Posts: 692 |
Thanked: 264 times |
Joined on Dec 2009
|
#119
|
#! /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: | ||
|
|
2010-01-19
, 13:59
|
|
Posts: 47 |
Thanked: 1 time |
Joined on Nov 2009
|
#120
|
| The Following User Says Thank You to tuxian For This Useful Post: | ||
![]() |
| Tags |
| cifs, ntfs, samba, smb, truecrypt |
| Thread Tools | |
|