Results 1 to 4 of 4

Thread: better .bash_history?

  1. #1
    Join Date
    May 2009
    Location
    Bradford UK
    Beans
    45
    Distro
    Ubuntu 10.04 Lucid Lynx

    better .bash_history?

    i know we can use the history command and itll come up with like
    1 ssh ...
    2 ls -l

    etc, is there a way to set it up to capture what the command prints out?

    for example if i use custom command awe use at work lets say "db" to search database and it brings up - name - server - password and things like that, is there anything i can set in a .bash* file to capture that so to speak a more advanced bash history

    Ive looked online and i cant find anything like this

    Can anybody advise any solution which would fit my desire?

    apologies that doesnt appear too clear i mean for all commands aswell for example bash_history will say
    ping google.com


    but i wish it to say something along the lines of

    ping google.com
    PING google.com (209.85.148.99): 56 data bytes
    64 bytes from 209.85.148.99: icmp_seq=0 ttl=52 time=22.690 ms
    64 bytes from 209.85.148.99: icmp_seq=1 ttl=52 time=21.933 ms
    ^C
    --- google.com ping statistics ---
    2 packets transmitted, 2 packets received, 0% packet loss
    round-trip min/avg/max/stddev = 21.933/22.312/22.690/0.378 ms


    hopefully this is more clear

    Thanks in advanced

    Sam
    A man who won't die for something is not fit to live.
    Martin Luther King, Jr.

  2. #2
    Join Date
    Jun 2011
    Location
    The Shadow Gallery
    Beans
    6,744

    Re: better .bash_history?

    Quote Originally Posted by lolium View Post
    i know we can use the history command and itll come up with like
    1 ssh ...
    2 ls -l

    etc, is there a way to set it up to capture what the command prints out?

    for example if i use custom command awe use at work lets say "db" to search database and it brings up - name - server - password and things like that, is there anything i can set in a .bash* file to capture that so to speak a more advanced bash history

    Ive looked online and i cant find anything like this

    Can anybody advise any solution which would fit my desire?

    Thanks in advanced

    Sam
    you can redirect all output to a text file with > filename.txt

    not sure if you can store that in the command history though, i think it is a per command basis
    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

  3. #3
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    tee

    Quote Originally Posted by haqking View Post
    you can redirect all output to a text file with > filename.txt

    not sure if you can store that in the command history though, i think it is a per command basis
    You can do something like this:

    Code:
    bash 2>&1 | tee /tmp/filename.txt
    That will get everything.

  4. #4
    Join Date
    Sep 2011
    Location
    London
    Beans
    384

    Re: better .bash_history?

    Quote Originally Posted by lolium View Post
    etc, is there a way to set it up to capture what the command prints out?
    Hi Sam

    There are two ways to do this which might help you, both designed for making teaching materials or logging what you're doing for your notes. I don't know that either is suitable for running all the time though.

    1. script

    This is a program which is like a shell, but which makes the file you describe.
    Do this:
    Code:
    cd /tmp
    script
    And then in that 'shell', do
    Code:
    pwd
    exit
    It makes this file:
    Code:
    Script started on Wed 26 Oct 2011 13:15:59 BST
    $ pwd
    /tmp
    $ exit
    exit
    Script done on Wed 26 Oct 2011 13:16:09 BST
    See http://manpages.ubuntu.com/manpages/.../script.1.html

    2. xterm logging

    You can run an xterm with the flag -l for logging, and you get a very similar result. I don't believe that the default Gnome terminal will do this.
    Code:
    xterm -l
    Makes a file called for example Xterm.log.computer.2011.10.26.13.12.46.6810

    http://manpages.ubuntu.com/manpages/...1/xterm.1.html

    Hope those help.

    Kind regards
    Jonathan.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •