How do I rid myself of the ' in this variable substitution?

  • Follow


Hi All,

I need some bash help.  I am tearing my hair out trying to get this
variable substitution
to work.  I keep getting four extra single quote which messes up my
command line.

Seamless='-A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"'
Line1="-N -d foo -a 16 -u $RemoteUsername"
if [ -n "$Password" ]; then Line1="$Line1 -p $Password"; fi
if [ -z "$Seamless" ]; then Line1="$Line1 -g $PercentScreen"; fi
/usr/bin/rdesktop $Line1 \
                  -r printer:'OKI_DATA_CORP_B4200'='HP LaserJet IIP' \
                  -r printer:'HP_Deskjet_F4200_series'='HP Deskjet
F4100 series' \
                  -r disk:MyLocalDrive=/Users/$LocalUsername/Desktop \
                  -r clipboard:CLIPBOARD \
                  ${Seamless} \
                  $IP

Running "#!/bin/bash -x" shows "${Seamless}" gets substituted with

    -A -s '"C:\seamlessrdp\seamlessrdpshell.exe' 'Notepad.exe"'

which error out as I suddenly have four extra single quotes.  It
should look like

    -A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"

How do I get rid of those four extra stinking single quotes?

Many thanks,
-T

0
Reply toddandmargo3 (1) 3/10/2010 3:19:31 AM

From: ToddAndMargo <toddandmargo@gmail.com>
Date: Tue, 9 Mar 2010 19:19:31 -0800 (PST)
> Hi All,
>
> I need some bash help.  I am tearing my hair out trying to get this
> variable substitution
> to work.  I keep getting four extra single quote which messes up my
> command line.
>
> Seamless='-A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"'
> Line1="-N -d foo -a 16 -u $RemoteUsername"
> if [ -n "$Password" ]; then Line1="$Line1 -p $Password"; fi
> if [ -z "$Seamless" ]; then Line1="$Line1 -g $PercentScreen"; fi
> /usr/bin/rdesktop $Line1 \
>                   -r printer:'OKI_DATA_CORP_B4200'='HP LaserJet IIP' \
>                   -r printer:'HP_Deskjet_F4200_series'='HP Deskjet
> F4100 series' \
>                   -r disk:MyLocalDrive=/Users/$LocalUsername/Desktop \
>                   -r clipboard:CLIPBOARD \
>                   ${Seamless} \
>                   $IP
>
> Running "#!/bin/bash -x" shows "${Seamless}" gets substituted with
>
>     -A -s '"C:\seamlessrdp\seamlessrdpshell.exe' 'Notepad.exe"'
>
> which error out as I suddenly have four extra single quotes.  It
> should look like
>
>     -A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"
>
> How do I get rid of those four extra stinking single quotes?
>
I get the feeling those stinking single quotes are added by the bash -x
execution. Notice this sample file and the -x execution output (bash 

$ cat test.sh
#!/bin/bash
a='a "b"'
b='a b'
c="a b"
echo ${a}
$ sh -x ./test.sh
+ [ 130319.100636300] a='a "b"'
+ [ 130319.241259500] b='a b'
+ [ 130319.397507500] c='a b'
+ [ 130319.581307000] echo a '"b"' 
a "b"
$

bash 3.2.49(23)-release (i686-pc-cygwin) here.

see that the assignment for c shows up with single quotes during -x
execution?

Kind regards,
Jurriaan
-- 
prachtige geschenken, exclusieve cadeaus: handgemaakte houten schalen

http://www.houtenschalen.nl
0
Reply thunder8 3/10/2010 12:06:45 PM


On 03/10/10 07:06, thunder8 wrote:
> From: ToddAndMargo<toddandmargo@gmail.com>
> Date: Tue, 9 Mar 2010 19:19:31 -0800 (PST)
>> Hi All,
>>
>> I need some bash help.  I am tearing my hair out trying to get this
>> variable substitution
>> to work.  I keep getting four extra single quote which messes up my
>> command line.
>>
>> Seamless='-A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"'
>> Line1="-N -d foo -a 16 -u $RemoteUsername"
>> if [ -n "$Password" ]; then Line1="$Line1 -p $Password"; fi
>> if [ -z "$Seamless" ]; then Line1="$Line1 -g $PercentScreen"; fi
>> /usr/bin/rdesktop $Line1 \
>>                    -r printer:'OKI_DATA_CORP_B4200'='HP LaserJet IIP' \
>>                    -r printer:'HP_Deskjet_F4200_series'='HP Deskjet
>> F4100 series' \
>>                    -r disk:MyLocalDrive=/Users/$LocalUsername/Desktop \
>>                    -r clipboard:CLIPBOARD \
>>                    ${Seamless} \
>>                    $IP
>>
>> Running "#!/bin/bash -x" shows "${Seamless}" gets substituted with
>>
>>      -A -s '"C:\seamlessrdp\seamlessrdpshell.exe' 'Notepad.exe"'
>>
>> which error out as I suddenly have four extra single quotes.  It
>> should look like
>>
>>      -A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"
>>
>> How do I get rid of those four extra stinking single quotes?
>>
> I get the feeling those stinking single quotes are added by the bash -x
> execution. Notice this sample file and the -x execution output (bash
>
> $ cat test.sh
> #!/bin/bash
> a='a "b"'
> b='a b'
> c="a b"
> echo ${a}
> $ sh -x ./test.sh
> + [ 130319.100636300] a='a "b"'
> + [ 130319.241259500] b='a b'
> + [ 130319.397507500] c='a b'
> + [ 130319.581307000] echo a '"b"'
> a "b"
> $
>
> bash 3.2.49(23)-release (i686-pc-cygwin) here.
>
> see that the assignment for c shows up with single quotes during -x
> execution?
>
> Kind regards,
> Jurriaan

Try "${a}" or "${Seamless}" (with quotes).
0
Reply Joe 3/10/2010 6:28:49 PM

On 2010-03-10, ToddAndMargo <toddandmargo@gmail.com> wrote:
> Hi All,
>
> I need some bash help.  I am tearing my hair out trying to get this
> variable substitution
> to work.  I keep getting four extra single quote which messes up my
> command line.
>
> Running "#!/bin/bash -x" shows "${Seamless}" gets substituted with
>
>     -A -s '"C:\seamlessrdp\seamlessrdpshell.exe' 'Notepad.exe"'
>
> which error out as I suddenly have four extra single quotes.  It
> should look like
>
>     -A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"
>
> How do I get rid of those four extra stinking single quotes?
>
> Many thanks,
> -T
>
You want the shell to interpret
  -A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"
as three arguments, not one or four. You can either break it into
three variables, or use eval, which may require rewriting the
rest of the multi-line command.
 
0
Reply Bill 3/10/2010 8:14:39 PM

(see previous message)
Or maybe you could change "${Seamless}" to
$(eval echo "$Seamless")

0
Reply Bill 3/10/2010 8:17:44 PM

On 2010-03-10, Bill Marcum <marcumbill@bellsouth.net> wrote:
> On 2010-03-10, ToddAndMargo <toddandmargo@gmail.com> wrote:
>> Hi All,
>>
>> I need some bash help.  I am tearing my hair out trying to get this
>> variable substitution
>> to work.  I keep getting four extra single quote which messes up my
>> command line.
>>
>> Running "#!/bin/bash -x" shows "${Seamless}" gets substituted with
>>
>>     -A -s '"C:\seamlessrdp\seamlessrdpshell.exe' 'Notepad.exe"'
>>
>> which error out as I suddenly have four extra single quotes.  It
>> should look like

Then why did you define Seamless as you did? Bash is simply doing what
you told it to do.
Where do you define Seamless, and what is its value?


>>
>>     -A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"
>>
>> How do I get rid of those four extra stinking single quotes?

By not defining the variable Seamless as you do.

>>
>> Many thanks,
>> -T
>>
> You want the shell to interpret
>   -A -s "C:\seamlessrdp\seamlessrdpshell.exe Notepad.exe"
> as three arguments, not one or four. You can either break it into
> three variables, or use eval, which may require rewriting the
> rest of the multi-line command.
>  
0
Reply unruh 3/10/2010 9:07:16 PM

On 03/10/2010 04:06 AM, thunder8 wrote:

> I get the feeling those stinking single quotes are added by the bash -x
> execution. Notice this sample file and the -x execution output (bash

Hi Jurriaan,

And you would be correct on that one.  Bill suggestion
of using the "eval" command corrected that problem.

Thank you!

-T

0
Reply Todd 3/11/2010 6:41:37 PM

On 03/10/2010 12:17 PM, Bill Marcum wrote:
> (see previous message)
> Or maybe you could change "${Seamless}" to
> $(eval echo "$Seamless")
>

Hi Bill,

You called it.  I put my huge run sting into
the "eval" command and happy camping has returned.

Thank you!

-T
0
Reply Todd 3/11/2010 6:42:53 PM

7 Replies
360 Views

(page loaded in 0.081 seconds)

Similiar Articles:













7/23/2012 10:55:32 AM


Reply: