<div class="gmail_quote">On Tue, Sep 29, 2009 at 2:02 PM, C. Titus Brown <span dir="ltr">&lt;<a href="mailto:ctb@msu.edu">ctb@msu.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

On Tue, Sep 29, 2009 at 02:01:31PM -0400, <a href="mailto:duraira1@msu.edu">duraira1@msu.edu</a> wrote:<br>
&gt; Hi,<br>
&gt; I just realised the format of how data given in the client affects my program..<br>
&gt; ?<br>
&gt; &gt;python client.py ?5001 &quot;sdd\n.\nddd&quot;<br>
&gt;<br>
&gt; In the above case,I got the right answer,<br>
&gt;<br>
&gt; Recieved from the server: sdd<br>
&gt; &lt;186 arctic:~/cde491 &gt;<br>
&gt;<br>
&gt; But incase I don&#39;t give the quotes,its kinda messy..Should I handle this in the server? Or the client is supposed to enter the data as string?<br>
<br>
There aren&#39;t any restrictions on how clients of the TCP echo server work, run,<br>
or otherwise take in data -- make it as freeform as you want.<br>
<br>
cheers,<br>
--titus<br>
<font color="#888888">--<br>
C. Titus Brown, <a href="mailto:ctb@msu.edu">ctb@msu.edu</a><a href="http://lists.idyll.org/listinfo/cse491-fall-2009" target="_blank"></a></font></blockquote><div><br> </div></div>You need the quotes because entering \n on the command-line results in the shell parsing it as &quot;n&quot;, then passing on that &quot;n&quot; to the echo client.  To examine how python will read in command-line arguments, run this command followed by the command-line arguments that you are uncertain about:<br>

<br><span style="font-family: courier new,monospace;">python -c &quot;print __import__(&#39;sys&#39;).argv[1:]&quot;</span><br><br>In the case of <span style="font-family: courier new,monospace;">sdd\n.\nddd</span>, we get <span style="font-family: courier new,monospace;">&#39;sddn.nddd&#39;</span>, suggesting (correctly) that &quot;<span style="font-family: courier new,monospace;">\n</span>&quot; on the command line is an escape sequence that resolves to just the leter &quot;<span style="font-family: courier new,monospace;">n</span>&quot;.  To get the results you want without quoting, you would have to escape the backslash on the command line:<br>

<br><span style="font-family: courier new,monospace;">python client.py ?5001 sdd\\n.\\nddd</span><br><br>This explanation, however, is irrelevant to the operation of your echo server.  If it helps give an insight to the way that UNIX-like shells operate, then great!  If it adds confusion, then you can safely ignore it, and just take this piece of advice: individual command-line arguments with non-alphanumeric characters (such as <span style="font-family: courier new,monospace;">&quot;\&quot;, &quot;$&quot;, &quot;*&quot;, &quot; &quot;,</span> etc) should be escaped with single quotes (<span style="font-family: courier new,monospace;">&#39; ... &#39;</span>) to preserve the literal interpretation of those characters.<br>

<br>--Joe<br>