Results 1 to 10 of 10

Thread: Recording Terminal to a .txt file

  1. #1
    Join Date
    Dec 2012
    Beans
    10

    Question Recording Terminal to a .txt file

    So I have a terminal session open to keep some stuff going for upwards of 10 hours of a time and I need a way to record the information outputted in the terminal to a text file as it is running. That means no stopping the script, just recording what the script says as it is running.

    Is it possible?

    If so, how would I go about it?

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

    Re: Recording Terminal to a .txt file

    Quote Originally Posted by Carbonwyre View Post
    So I have a terminal session open to keep some stuff going for upwards of 10 hours of a time and I need a way to record the information outputted in the terminal to a text file as it is running. That means no stopping the script, just recording what the script says as it is running.

    Is it possible?

    If so, how would I go about it?
    Code:
    scriptname > /location/textfile
    it is the same in Windows also,. incase you wanted to know, although the solidus is primarily a Linux thing, and \ is used in Windows, contrary to popular belief you can still use a solidus for filepaths in Windows
    Last edited by haqking; December 13th, 2012 at 12:04 PM.
    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

  3. #3
    Join Date
    Oct 2008
    Location
    colachel
    Beans
    517
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Recording Terminal to a .txt file

    Redirect the command or script using .txt file.

    Ex) ls> output.txt 2>&1

  4. #4
    Join Date
    Dec 2012
    Beans
    10

    Re: Recording Terminal to a .txt file

    Quote Originally Posted by haqking View Post
    Code:
    scriptname > /location/textfile
    it is the same in Windows also,. incase you wanted to know, although the solidus is primarily a Linux thing, and \ is used in Windows, contrary to popular belief you can still use a solidus for filepaths in Windows
    So simply XXXXX.sh >/pathtofile/file ?

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

    Re: Recording Terminal to a .txt file

    Quote Originally Posted by Carbonwyre View Post
    So simply XXXXX.sh >/pathtofile/file ?

    well that was what i wrote

    For further reading to assist try this http://www.tuxfiles.org/linuxhelp/iodirection.html
    Last edited by haqking; December 13th, 2012 at 12:15 PM.
    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

  6. #6
    Join Date
    Dec 2012
    Beans
    10

    Re: Recording Terminal to a .txt file

    Quote Originally Posted by haqking View Post
    well that was what i wrote

    For further reading to assist try this http://www.tuxfiles.org/linuxhelp/iodirection.html
    Thanks ^_^ for a new using sometimes it's hard to wrap my head around some things. So even though I might read it 3-4 times elsewhere I still have to ask just to make sure I'm not typing 1 things wrong and confusing myself forever.

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

    Re: Recording Terminal to a .txt file

    Quote Originally Posted by Carbonwyre View Post
    Thanks ^_^ for a new using sometimes it's hard to wrap my head around some things. So even though I might read it 3-4 times elsewhere I still have to ask just to make sure I'm not typing 1 things wrong and confusing myself forever.

    No problem, please mark the thread as solved using thread tools to help others when searching.

    Cheers
    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

  8. #8
    Join Date
    Dec 2012
    Beans
    10

    Re: Recording Terminal to a .txt file

    Quote Originally Posted by haqking View Post
    No problem, please mark the thread as solved using thread tools to help others when searching.

    Cheers
    I just tried out the command and the recorded document looks like

    208
    27
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >stop
    >
    >
    >
    >
    And that's the short version. The problem is that the script actually put out quite a bit of information but it wasn't recorded.

    The information is outputted from a Java Runtime and most the information is coming from the runtime not the script itself. It is displayed in the terminal but not generated by the terminal.

    Any advice?

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

    Re: Recording Terminal to a .txt file

    Perhaps some of the script was sending data to stderr in addition to stdout. You can try capturing both.

    Code:
    scriptname > /location/textfile 2>&1
    You can also use the script utility to record a session.

  10. #10
    Join Date
    Dec 2012
    Beans
    10

    Re: Recording Terminal to a .txt file

    Quote Originally Posted by Lars Noodén View Post
    Perhaps some of the script was sending data to stderr in addition to stdout. You can try capturing both.

    Code:
    scriptname > /location/textfile 2>&1
    You can also use the script utility to record a session.
    I tried out the script utility first and it works ^_^ Thank you both I'm sure these questions get tiring to answer after 5k posts.

Tags for this Thread

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
  •