<br><br><div class="gmail_quote">On Wed, Mar 17, 2010 at 9:54 AM, ashwini yal <span dir="ltr"><<a href="mailto:ashwiniyal@gmail.com">ashwiniyal@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br><br>I am writing a python script which logs into the machine using pxssh, sends a command, reads the response and writes the response to the file.<br><br>But, when I open the file in the editor like vi, its showing special characters like ^M and ^[[D instead of spaces or newlines.<br>

<br>This is how my code looks like ...<br><br>s = pxssh.pxssh()<br>s.login(ip, username, password)<br><br>cmd = 'xyz'<br>s.sendline (cmd)<br>s.prompt()<br>output = s.before<br>fileWrite = open(filePath , 'wb')<br>

fileWrite.write(output)<br>s.prompt()   <br><br><br>This is how my filePath looks like when I open it using vi editor.<br><br>Starting command execution on host xxx.xxx.xxx.xxx<br><br>D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^M<br>

<br>Command executed successfully ^M<br>                  <br>Executing next command ...^M<br><font color="#888888"><br></font></blockquote><div><br>I don't know what's going with the ^[[D, but ^M is a carriage return. Your connection is returning CRLF ("\r\n") for the line endings (which is what Windows uses for line endings) instead of the Unix line ending, which is just a line feed "\n".<br>
</div><br></div>