LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-14-2012, 04:52 PM   #1
priyankgupta1984
LQ Newbie
 
Registered: Sep 2011
Posts: 17

Rep: Reputation: Disabled
Question problem in shell script for dhcp


I am creating a script to configure dhcp and I am just getting one problem. I want to pass Domain name as "myscript.com" but in dhcpd.conf I am only getting myscript.com with out quotes. I am also mentioning my coding for the same

echo "Enter Domain name: "
read $dname

echo " option domain-name "$dname"; >> /etc/dhcp/dhcpd.conf

Output

option domain-name myscript.com;

However I want this myscript.com in double quotes

Can any one please tell me what I am doing wrong
 
Old 06-14-2012, 04:58 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
You will need to escape it. Or use echo with -e option and use these: http://tldp.org/HOWTO/Bash-Prompt-HO...sequences.html and specify the octal number for a backslash.

Easier option would be to switch it to this:

"\"$dname\""
 
1 members found this post helpful.
Old 06-14-2012, 05:00 PM   #3
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
To explain a bit more... when a special character is preceded by a backslash, \, it is treated literally and not expanded to its special value.
 
1 members found this post helpful.
Old 06-14-2012, 05:39 PM   #4
priyankgupta1984
LQ Newbie
 
Registered: Sep 2011
Posts: 17

Original Poster
Rep: Reputation: Disabled
Thumbs up @Kustom42

Thanks man you rocks it worked thanks for your time and support
 
Old 06-14-2012, 05:40 PM   #5
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
No worries, this forum keeps me sane during my slow time at work. You can mark the thread as solved under the "thread tools" drop down menu on top.
 
  


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
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 10:12 PM
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 08:58 PM
shell script problem bondoq Linux - Newbie 6 07-03-2006 03:45 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM


All times are GMT -5. The time now is 06:30 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration