Re: Double backslash behavior not as expected
- From: "Dan Mercer" <damercer@xxxxxxxxxxx>
- Date: Fri, 4 May 2007 08:19:42 -0500
"John W. Krahn" <someone@xxxxxxxxxxx> wrote in message news:Q5x_h.1690$Vi6.1400@xxxxxxxxxxx
: alt.testing@{g}mail.com wrote:
: > Hi all,
: > the simple concept of escaping a "backslash", thus translating to a
: > literal backslash; does not provide the implied result, under the
: > following example.
: >
: > $mount_result = qx#strace /bin/mount -t smbfs \\\\$machine\\documents
Use:
$mount_result = qx#strace /bin/mount -t smbfs '\\\\$machine\\documents'
which the shell will see as '\\an2\documents'
Dan Mercer
: > /mnt/workstation_shares/$mount/documents/ -o ro -o username=$user -o
: > password=$pass#;
: >
: > The top part of the "strace" output gives this:
: >
: > execve("/bin/mount", ["/bin/mount", "-t", "smbfs", "\\an2documents",
: > "/mnt/workstation_shares/xxxx/doc"..., "-o", "ro", "-o",
: > "username=xxxx", "-o", "password=xxxxxxxxxx"], [/* 22 vars */]) = 0
: >
: > "\\an2documents"
: >
: > Note; that there is no "\" in between the machine name, and the share.
: > It should be "\\an2\documents".
: >
: > [root@mercedes sbin]# perl -e 'print "\\\\an2\\documents\n"'
: > \\an2\documents
: >
: >
: > I'm sure it's a simple thing, but can someone enlighten me on this
: > parlay?
:
: Your string is interpolated twice, once by perl and then by the shell.
:
: $ perl -le'
: $machine = "an2";
: $mount = "xxxx";
: print qx#echo /bin/mount -t smbfs
: \\\\$machine\\documents/mnt/workstation_shares/$mount/documents/#;
: '
: /bin/mount -t smbfs \an2documents/mnt/workstation_shares/xxxx/documents/
:
:
: You need to double up on the back-slashes.
:
: $ perl -le'
: $machine = "an2";
: $mount = "xxxx";
: print qx#echo /bin/mount -t smbfs
: \\\\\\\\$machine\\\\documents/mnt/workstation_shares/$mount/documents/#;
: '
: /bin/mount -t smbfs \\an2\documents/mnt/workstation_shares/xxxx/documents/
:
:
:
:
:
: John
: --
: Perl isn't a toolbox, but a small machine shop where you can special-order
: certain sorts of tools at low cost and in short order. -- Larry Wall
.
- References:
- Double backslash behavior not as expected
- From: alt . testing
- Re: Double backslash behavior not as expected
- From: John W. Krahn
- Double backslash behavior not as expected
- Prev by Date: FAQ 5.7 How can I manipulate fixed-record-length files?
- Next by Date: Re: 2 array problem
- Previous by thread: Re: Double backslash behavior not as expected
- Next by thread: Re: Double backslash behavior not as expected
- Index(es):
Relevant Pages
|