Search code examples
linuxubuntutelnet

How do I put Output command telnet in file


How do I put Output command telnet in file ?

telnet www.google.com 80 > file.txt 
GET / /HTTP/1.1 

Why am I wrong?


Solution

  • It's correct...I don't know why its not work, but you can use tee to.

    command | tee ~/outputfile.txt
    

    A slight modification will catch stderr as well:

    command 2>&1 | tee ~/outputfile.txt
    

    or just the same with less characters to type:

    command |& tee ~/outputfile.txt
    

    tee is useful if you want to be able to capture command output while also viewing it live.