Reputation: 158
I am using Powershell to ssh into my Linux server and tailing my apache log files.
ssh [email protected] -p800 -i ..ssh\id_rsa_test tail /var/log/httpd/access_log -fn0 > test.log
When tailing the text looks fine, When opening the file I piped the text into it looks fine.
The application I am piping the output to fails. When I tail the file I am piping into I see every single character separated by a space.
using out-file with no parameters does the same thing. When I cut and paste the contents of the file in notepad to another notepad file, the other application can read it. How can I fix this?
Here's a sample of what I am referring to:
d o m a i n . c o m 7 2 . 2 2 4 . 2 4 9 . 1 7 - - [ 1 0 / D e c / 2 0 1 3 : 0 7 : 5 0 : 5 6 - 0 6 0 0 ] " G E T / v a n e / v i e w f o r u m . p h p ? f = 1 & s i d = 3 b 4 3 b d 9 9 9 a 7 d b 2 0 c 6 6 9 7 5 b 2 3 8 2 4 a 9 6 1 9 H T T P / 1 . 1 " 2 0 0 9 3 7 6 " h t t p : / / w w w . d o m a i n . c o m / j a n e / v i e w t o p i c . p h p ? f = 1 & t = 8 0 2 3 & p = 3 4 3 4 5 0 & s i d = 3 b 4 3 b d 9 9 9 a 7 d b 2 0 c 6 6 9 7 5 b 2 3 8 2 4 a 9 6 1 9 " " M o z i l l a / 4 . 0 ( c o m p a t i b l e ; M S I E 8 . 0 ;
W i n d o w s N T 6 . 0 ; W O W 6 4 ; T r i d e n t / 4 . 0 ; G T B 7 . 5 ; S L C C 1 ; . N E T C L R 2 . 0 . 5 0 7 2 7 ;
M e d i a C e n t e r P C 5 . 0 ; . N E T C L R 3 . 5 . 2 1 0 2 2 ; . N E T C L R 3 . 5 . 3 0 7 2 9 ; M D D C ; . N E T C L R 3 . 0 . 3 0 7 2 9 ; . N E T 4 . 0 C ; B R I / 1 ; B R I / 2 ) " d o m a i n . c o m 5 . 9 . 1 0 6 . 2 4 1 - - [ 1 0 / D e c / 2 0 1 3 : 0 7 : 5 0 : 5 8 - 0 6 0 0 ] " G E T / r o b o t s . t x t H T T P / 1 . 0 " 2 0 0 - " - " " M o z i l l a / 5 . 0 ( c o m p a t i b l e ; M J 1 2 b o t / v 1 . 4 . 4 ; h t t p : / / w w w . m a j e s t i c 1 2 . c o . u k / b o t . p h p ? + ) "
Upvotes: 1
Views: 2910
Reputation: 68273
If you pipe our output though out-file, set-conent, or add-content you can use the -Encoding parameter to force it to ASCII:
ssh [email protected] -p800 -i ..ssh\id_rsa_test tail /var/log/httpd/access_log -fn0 | Add-Content test.log -encoding ASCII
ssh [email protected] -p800 -i ..ssh\id_rsa_test tail /var/log/httpd/access_log -fn0 | Set-Content test.log -encoding ASCII
ssh [email protected] -p800 -i ..ssh\id_rsa_test tail /var/log/httpd/access_log -fn0 | Out-File test.log -encoding ASCII
Upvotes: 2