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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
02-03-2006, 03:30 PM
|
#1
|
|
LQ Newbie
Registered: Feb 2006
Posts: 6
Rep:
|
Shell scripting problem
Really simple shell scripting problem I am having... I am trying to mount the Documents and Settings directory of a Windows XP box on my Fedora server. I don't have any probelems connecting on the command line...
mount -t smbfs -o username=user,password=pass /XPMachine/Documents\ and\ Settings /mnt/tmp
but when I try to put the command in a script, the command doesn't work. I figure I am missing something with the escape characters, but don't have a clue what.
Any help is greatly appreciated.
--jb
|
|
|
|
02-03-2006, 03:54 PM
|
#2
|
|
Guru
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092
|
Usually you need to start your script file with #!/bin/bash and then chmod +x scriptname.sh. To use the script, you go to the directory and type ./scriptname.sh or place the script in a directory that is in your path and just invoke it by name.
|
|
|
|
02-03-2006, 04:04 PM
|
#3
|
|
LQ Newbie
Registered: Feb 2006
Posts: 6
Original Poster
Rep:
|
Ok, sorry, let me be more specific....
On the command line, the following command works fine...
mount -t smbfs -o username=user,password=pass /XPMachine/Documents\ and\ Settings /mnt/tmp
When I put the command into a script as follows it does not work...
#!/bin/bash
#
SHARE=//XPSystem/Documents\ and\ Settings
mount -t smbfs -o username=jbutler,password=buddy12 $SHARE /mnt/tmp
If I don't use the variable, the script works fine, just like on the command line... Once I use the variable the whole thing breaks...
--jb
|
|
|
|
02-03-2006, 04:14 PM
|
#4
|
|
Guru
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092
|
The only thing I can see off the top of my head is that in the script, the variable is //XPSystem/.... and in your command line it is /XPMachine. So guessing that the first one is generic, does the fact that the script has two "/" instead of one do anything?
|
|
|
|
02-03-2006, 04:17 PM
|
#5
|
|
Guru
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092
|
Another thing you might try is:
Code:
SHARE="/XPSystem/Documents and Settings"
|
|
|
|
02-03-2006, 04:17 PM
|
#6
|
|
LQ Newbie
Registered: Feb 2006
Posts: 6
Original Poster
Rep:
|
typo there would actually be // in front of XPMachine...
|
|
|
|
02-03-2006, 04:24 PM
|
#7
|
|
LQ Newbie
Registered: Feb 2006
Posts: 6
Original Poster
Rep:
|
I figured it out... all I needed to do is put the variable in " " as such
#!/bin/bash
#
SHARE=//XPSystem/Documents\ and\ Settings
mount -t smbfs -o username=jbutler,password=buddy12 "$SHARE" /mnt/tmp
Thx for the help everyone.
--jb
|
|
|
|
02-03-2006, 06:52 PM
|
#8
|
|
Senior Member
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853
Rep:
|
Although you've already figured it out, another way of sending the command is:

|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:56 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|