LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 02-03-2006, 04:30 PM   #1
ecsjohn
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Rep: Reputation: 0
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
 
Old 02-03-2006, 04:54 PM   #2
pljvaldez
Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092

Rep: Reputation: 269Reputation: 269Reputation: 269
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.
 
Old 02-03-2006, 05:04 PM   #3
ecsjohn
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
Old 02-03-2006, 05:14 PM   #4
pljvaldez
Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092

Rep: Reputation: 269Reputation: 269Reputation: 269
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?
 
Old 02-03-2006, 05:17 PM   #5
pljvaldez
Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092

Rep: Reputation: 269Reputation: 269Reputation: 269
Another thing you might try is:

Code:
SHARE="/XPSystem/Documents and Settings"
 
Old 02-03-2006, 05:17 PM   #6
ecsjohn
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Original Poster
Rep: Reputation: 0
typo there would actually be // in front of XPMachine...
 
Old 02-03-2006, 05:24 PM   #7
ecsjohn
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
Old 02-03-2006, 07:52 PM   #8
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
Although you've already figured it out, another way of sending the command is:
Code:
$(echo command)
 
  


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
Shell scripting problem for importing Firefox files montylee Programming 6 06-03-2005 02:52 AM
shell scripting: variable problem XST1 Programming 7 01-30-2005 02:45 PM
another cgi and shell scripting problem + webserver prinski Programming 6 04-08-2004 05:25 PM
Shell Scripting Problem linuxboy69 Linux - Software 2 03-31-2004 08:36 PM
problem in shell scripting visu Linux - Newbie 4 01-06-2004 05:16 PM


All times are GMT -5. The time now is 07:57 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration