<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">> ..... work the same? Is there any need to use backslashes here?<br> <br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">I always operate on the principle "if in doubt, escape it (i.e., backslash it)". Why spend time researching the bare minimum of escaping/backslashing needed, when you can be safer as well as pre-empt future backslashing requirements (if additional characters become special). This also makes the code more readable (yeah!).<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"> <br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">I primarily apply this principle in regular expressions, but it is sensible here too.<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"> <br></div><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font size="2"><span style="font-family:verdana,sans-serif">Hartmut W Sager - Tel +1-204-339-8331, +1-204-515-1701, +1-204-515-1700, +1-810-471-4600<br></span></font><br></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On 12 December 2016 at 13:57, Kevin McGregor <span dir="ltr"><<a href="mailto:kevin.a.mcgregor@gmail.com" target="_blank">kevin.a.mcgregor@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Ugh. Even under Windows, doesn't<div><br></div><div><span style="color:rgb(80,0,80);font-size:12.8px">$cmd = "./psexec.exe //" . $server_name</span><br></div><div><span style="color:rgb(80,0,80);font-size:12.8px"><br></span></div><div><span style="color:rgb(80,0,80);font-size:12.8px">work the same? Is there any need to use backslashes here?</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 12, 2016 at 1:53 PM, Gilbert E. Detillieux <span dir="ltr"><<a href="mailto:gedetil@cs.umanitoba.ca" target="_blank">gedetil@cs.umanitoba.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Yup, makes sense now...<br>
<br>
After this line...<span><br>
<br>
$cmd = "./psexec.exe \\\\\\\\" . $server_name<br>
<br></span>
... the cmd variable will contain "./psexec.exe \\\\server" (4 backslashes. On running this line...<br>
<br>
my $output = `$cmd`<br>
<br>
... the shell will see "./psexec.exe \\\\server", and the command will see (after shell quote processing) argv[1] set to "\\server".<br>
<br>
Each level of "\" escape processing requires that you double the number of "\" characters entered to get one through. If you want to end up with 2, after 2 levels, you need 8.<br>
<br>
Gilbert<span><br>
<br>
On 12/12/2016 1:43 PM, Kevin McGregor wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>
I should add that this gets run immediately after via<br>
<br>
my $output = `$cmd`<br>
<br>
if that makes any difference.<br>
<br>
On Mon, Dec 12, 2016 at 1:40 PM, Kevin McGregor<br></span><span>
<<a href="mailto:kevin.a.mcgregor@gmail.com" target="_blank">kevin.a.mcgregor@gmail.com</a> <mailto:<a href="mailto:kevin.a.mcgregor@gmail.com" target="_blank">kevin.a.mcgregor@gmail<wbr>.com</a>>> wrote:<br>
<br>
I'm trying to decipher some Perl code which runs on a Windows<br>
server, and I ran into this:<br>
<br>
$cmd = "./psexec.exe \\\\\\\\" . $server_name<br>
<br>
I think the idea is to end up with<br>
<br>
./psexec.exe \\server<br>
<br>
but WTF eight backslashes? Does that make any sense? If so, can<br>
someone ELI5?<br>
<br>
Kevin<br>
</span></blockquote><span class="gmail-m_-2704763719617070381HOEnZb"><font color="#888888">
<br><span class="gmail-HOEnZb"><font color="#888888">
-- <br>
Gilbert E. Detillieux E-mail: <<a href="mailto:gedetil@cs.umanitoba.ca" target="_blank">gedetil@cs.umanitoba.ca</a>><br>
Dept. of Computer Science Web: <a href="http://www.cs.umanitoba.ca/%7Egedetil/" rel="noreferrer" target="_blank">http://www.cs.umanitoba.ca/~ge<wbr>detil/</a><br>
University of Manitoba Phone: <a href="tel:%28204%29474-8161" value="+12044748161" target="_blank">(204)474-8161</a><br>
Winnipeg MB CANADA R3T 2N2 Fax: <a href="tel:%28204%29474-7609" value="+12044747609" target="_blank">(204)474-7609</a><br>
______________________________<wbr>_________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.ca" target="_blank">Roundtable@muug.ca</a><br>
<a href="https://muug.ca/mailman/listinfo/roundtable" rel="noreferrer" target="_blank">https://muug.ca/mailman/listin<wbr>fo/roundtable</a><br>
</font></span></font></span></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.ca">Roundtable@muug.ca</a><br>
<a href="https://muug.ca/mailman/listinfo/roundtable" rel="noreferrer" target="_blank">https://muug.ca/mailman/<wbr>listinfo/roundtable</a><br>
<br></blockquote></div><br></div></div>