Find the answer to your Linux question:
Results 1 to 8 of 8
I recently developed a program to capture command line input/output and share on the web. It is open source and can be found at: github.com/dtannen/monitor Alternatively, you can upload scripts ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2014
    Posts
    5

    Monitor input/output capture


    I recently developed a program to capture command line input/output and share on the web.

    It is open source and can be found at: github.com/dtannen/monitor

    Alternatively, you can upload scripts to share via commands.com.

    I tried to allow scripts to be runnable from the command line directly using something like "curl commands.io/compress | sh"

    You can use sh -s to send args to the scripts

    Feedback appreciated.
    Last edited by dtannen; 07-11-2014 at 05:30 PM.

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    649
    The "already developed and supplied command" to capture of your terminal session is called "script" (script - make typescript of terminal session) found in the "sys-apps/util-linux" package. The web site is "http://www.kernel.org/pub/linux/utils/util-linux/".

    So what does your script do that "script" does not do?

  3. #3
    Just Joined!
    Join Date
    Jul 2014
    Posts
    5

    monitor vs script

    Monitor sends captured commands to commands.com for sharing, forking, etc.

    Monitor also captures "vi" edits and automatically stored the diff.

    You can also re-run the commands using curl commands.io/COMMAND

  4. #4
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    649
    Thank you.

    Is the "diff" simply a diff or is it a "patch" file for the "patch" command?

    I hope that the next time you replace an existing command with something new and advertise it, you will include a comparison and a benefits list because that will help people decide if they like to try it or not.

    I for one do not like applications that just send stuff onto the network without getting approval just before sending the data. I am the person and I should be in control (main reason I never use a certain large company's OS (Hint: that company announces a 18,000 employee lay off even as they fight for more HB-1 visas).

  5. #5
    Just Joined!
    Join Date
    Jul 2014
    Posts
    5

    I agree

    Monitor is open source... and I would welcome a pull request that adds a (y/n) after exit to allow user to prevent commands from being sent over the network. The send is https and if you use the -u username option, they will only be accessible by you and you can immediately delete them from commands.com.

    Since the entire code for Monitor is open source, you can see exactly what it is doing and can make any changes you want.

    Pretty sure the company you are referring to doesn't open source their software.

  6. #6
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    649
    I did find an error in handling the "~". Please not that you do not handle
    Code:
    cd ~freddiek/Documents
    if I am user "alf55" as you do not handle the "~username" in your code. You are also not handling the other cases such as "~-", "!+" =, etc at all. From the bash manual:
    Code:
    If a word begins with an unquoted tilde character (‘~’), all of the characters up to the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix. If none of the characters in the tilde-prefix are quoted, the characters in the tilde-prefix following the tilde are treated as a possible login name. If this login name is the null string, the tilde is replaced with the value of the HOME shell variable. If HOME is unset, the home directory of the user executing the shell is substituted instead. Otherwise, the tilde-prefix is replaced with the home directory associated with the specified login name.
    
    If the tilde-prefix is ‘~+’, the value of the shell variable PWD replaces the tilde-prefix. If the tilde-prefix is ‘~-’, the value of the shell variable OLDPWD, if it is set, is substituted.
    
    If the characters following the tilde in the tilde-prefix consist of a number N, optionally prefixed by a ‘+’ or a ‘-’, the tilde-prefix is replaced with the corresponding element from the directory stack, as it would be displayed by the dirs builtin invoked with the characters following tilde in the tilde-prefix as an argument (see The Directory Stack). If the tilde-prefix, sans the tilde, consists of a number without a leading ‘+’ or ‘-’, ‘+’ is assumed.
    
    If the login name is invalid, or the tilde expansion fails, the word is left unchanged.
    
    Each variable assignment is checked for unquoted tilde-prefixes immediately following a ‘:’ or the first ‘=’. In these cases, tilde expansion is also performed. Consequently, one may use file names with tildes in assignments to PATH, MAILPATH, and CDPATH, and the shell assigns the expanded value.
    
    The following table shows how Bash treats unquoted tilde-prefixes:
    
    ~
    
        The value of $HOME 
    ~/foo
    
        $HOME/foo
    ~fred/foo
    
        The subdirectory foo of the home directory of the user fred
    ~+/foo
    
        $PWD/foo
    ~-/foo
    
        ${OLDPWD-'~-'}/foo
    ~N
    
        The string that would be displayed by ‘dirs +N’
    ~+N
    
        The string that would be displayed by ‘dirs +N’
    ~-N
    
        The string that would be displayed by ‘dirs -N’
    Also you do not handle any environment variable in the path. You also would not handle the commands:
    Code:
    cd ${HOME}/Docuemnts
    cd ~/issues/
    The shell not the library "chdir" does the expansion.
    [/code]
    On my system the command "vi" (runs vim in strict vi mode), vim runs in vim mode, gvim runs in a gui mode with fall back to text mode. Also what does your script do when I enter a ":w somefilename", ":e somefilename", or "!!ls somepath" while in vi/vim? I also do ntot see it handing bash commands such as:
    Code:
    cd some_path
    for d in {0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f}{0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f}{0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f}; do find ./${d} -type f -print | wc -l ; done > ${DATADIR}/counts_in_some_path
    The command "script" would have handled all of these cases.

  7. #7
    Just Joined!
    Join Date
    Jul 2014
    Posts
    5
    Truthfully-- script doesn't handle all these cases. Script doesn't do anything with vi edits. Script functions completely differently -- it basically listens to all the output from shell in another process. The issue with this approach is all of the special characters that it can't filter out. You wind up getting lines like
    Code:
    ESC[?1034hbash-3.2$ ls
    However, I acknowledge that Monitor has deficiencies. Each of the cases you mentioned needs to be handled separately in Monitor whereas script is not its own shell-- it is just relaying data between terminal and pty master.

    If you submit bugs in github, I will happily start fixing some of the items you mentioned.

  8. #8
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    649
    "script" captures all my key strokes and output generated while in vim. But I use xterm not gterminal or konsole. Granted it is very hard to read. As your product stands it is several years before it will be ready for use in my day-to-day usage (too primitive at this time, and I don't have time to write enough tickets into github).

Posting Permissions

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