LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   problem in shell script for dhcp (https://www.linuxquestions.org/questions/linux-newbie-8/problem-in-shell-script-for-dhcp-4175411495/)

priyankgupta1984 06-14-2012 03:52 PM

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

Kustom42 06-14-2012 03:58 PM

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\""

Kustom42 06-14-2012 04:00 PM

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.

priyankgupta1984 06-14-2012 04:39 PM

@Kustom42
 
Thanks man you rocks it worked thanks for your time and support

Kustom42 06-14-2012 04:40 PM

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.


All times are GMT -5. The time now is 09:15 AM.