No such thing as a small change | |
PerlMonks |
odd escape chars in strings obtained by SSHby danmcb (Monk) |
on Oct 11, 2007 at 14:38 UTC ( [id://644255]=perlquestion: print w/replies, xml ) | Need Help?? |
danmcb has asked for the wisdom of the Perl Monks concerning the following question: Here's a little secure shell puzzler for you monks. I'm using Net::SSH::Expect to connect to a remote machine, run commands and grab their output, for testing purposes. I wrapped the whole thing in an object, which has an "exec" method which is like that of N:S:E, except that it will remove the prompt, return either an array ref or a string depending on context - and chomp newlines. Ah, new lines. Chomp just doesn't seem to work here. I check the value of $\, and then start looking at the output using unpack to hexdump. There is some odd stuff here - I guess this is to do with ssh operation, butI can't figure it, or find anything about it online ...
Here's some code and what I get. My main module:
and here is the exec method in TestRobot:
(the chomp removes zero chars, by the way). Finally, here is what I get when I uncomment those prints, and redirect the output to a file. Not that the odd ^[[ sequences don't show up when you run it in a terminal!
What I would like to do is filter this down do just raw ASCII, because otherwise it is going to make running tests on the output very messy. But how? options to ssh? (I do call "stty raw -echo" after connecting, as suggested in the docs. As always, all help is gratefully received.
Back to
Seekers of Perl Wisdom
|
|