LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 08-21-2004, 09:28 PM   #1
evilchild
Member
 
Registered: Sep 2003
Location: 127.0.0.1
Distribution: *bsd, solaris, gentoo
Posts: 86

Rep: Reputation: 15
Question Double and single quote, Question in expect


I' m writing an expect script that is inside of a bash script and reads it's input from stdin, so I can define variables in the bash script that can be used in the expect script. But my problem is on the line
Code:
send "sudo useradd -c  '$NAME' -s /bin/sh -p '$PASS'  $USERNAME \r"
It returns an error because the $PASS variable contains an encrypted password,
which contains $'s which is reserved for expect variables, how can i quote this without receiving errors?

when this code is executed the command that runs actually looks like so
Code:
sudo useradd -c 'Tim Cook' -s /bin/sh -p '$2aHgs57dfdHdfsG3v' tim
Thanks Evilchild
 
Old 08-22-2004, 02:12 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,509

Rep: Reputation: 176Reputation: 176
I am not certain that this will work but you could try escaping the '

send "sudo useradd -c '$NAME' -s /bin/sh -p \'$PASS\' $USERNAME \r"

-------------------------
Steve Stites
 
Old 08-22-2004, 03:42 PM   #3
evilchild
Member
 
Registered: Sep 2003
Location: 127.0.0.1
Distribution: *bsd, solaris, gentoo
Posts: 86

Original Poster
Rep: Reputation: 15
no that still didn't work it tryed to execute, '
send "sudo useradd -c '$NAME' -s /bin/sh -p \'$PASS\' $USERNAME \r" ' and still got an error because of the encrypted pass .
 
Old 08-22-2004, 03:50 PM   #4
Charalambos
Member
 
Registered: Aug 2004
Location: Switzerland
Distribution: debian
Posts: 149

Rep: Reputation: 15
{$PASS}
 
Old 08-22-2004, 05:34 PM   #5
evilchild
Member
 
Registered: Sep 2003
Location: 127.0.0.1
Distribution: *bsd, solaris, gentoo
Posts: 86

Original Poster
Rep: Reputation: 15
for some reason '
send "sudo useradd -c '$NAME' -s /bin/sh -p {$PASS} $USERNAME \r" '
does not work for me, neither does
'
send "sudo useradd -c '$NAME' -s /bin/sh -p '{$PASS}' $USERNAME \r" '

or

'
send "sudo useradd -c '$NAME' -s /bin/sh -p {'$PASS'} $USERNAME \r" '
 
  


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
xargs: unmatched single quote akudewan Linux - Newbie 5 07-28-2014 12:16 PM
single click instead of double - opening folders dianat100 Mandriva 5 10-23-2005 04:44 PM
Need a site:DDR modules single sided/double sided RobertP Linux - Hardware 2 08-02-2004 04:32 PM
xargs: unmatched single quote fillatre Linux - Software 2 06-05-2004 10:04 PM
In BASH shell, what is the difference in usage between single and double quotes? davidas Linux - Newbie 2 04-05-2004 03:00 AM


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

Main Menu
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