'tee' doesn't work with mongo shell

168 views
Skip to first unread message

Jorge Puente Sarrín

unread,
Nov 15, 2012, 5:11:11 PM11/15/12
to mongod...@googlegroups.com
Hello guys,

On MongoDB Lima, we are trying solve 10gen Education homeworks, and somebody writes about this question:

http://groups.google.com/group/mongodb-lima/browse_thread/thread/a11765e250411320

When copy/paste any text with, shell shows strange/special characteres, including using backspace or arrow up for view last command.
 
Does exist any way to logging the shell I/O?

There are a attached video on this thread... Please, help us with this issue.

--
Jorge Puente Sarrín.

Ronald Stalder

unread,
Nov 16, 2012, 10:27:07 AM11/16/12
to mongod...@googlegroups.com
Hi Jorge,

in linux (don't know about Mac) you have the script command, but it has the same problem: for input it shows every backspace etc... You'll have to edit the output before copying/pasting
 

Jorge Puente Sarrín

unread,
Nov 16, 2012, 10:31:18 AM11/16/12
to mongod...@googlegroups.com
Sure,

But mongo shell crashes when I do it, It can be considered an issue? or not?

Thanks for response Ronald.


2012/11/16 Ronald Stalder <rona...@gmail.com>
Hi Jorge,

in linux (don't know about Mac) you have the script command, but it has the same problem: for input it shows every backspace etc... You'll have to edit the output before copying/pasting
 

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb



--
Jorge Puente Sarrín.

Ronald Stalder

unread,
Nov 16, 2012, 2:27:24 PM11/16/12
to mongod...@googlegroups.com
This is a copy/paste form my console (highlighting manually here in the textbox):

ronald@ronald-cce:~/curso-m101/hw3$ script --version
script de util-linux 2.20.1
ronald@ronald-cce:~/curso-m101/hw3$ script test.log
Script iniciado, o arquivo é test.log
ronald@ronald-cce:~/curso-m101/hw3$ mongo test
MongoDB shell version: 2.2.1
connecting to: test
> show collections
fruit
posts
system.indexes
test
videos.chunks
videos.files
videos_meta
> db.posts.findOne()
{
"_id" : ObjectId("509df08f27f819ffd9d9ef2d"),
"author" : "Jane",
"content" : "bla bla",
"comments" : [
{
"author" : "John",
"text" : "bloblo"
},
{
"author" : "Jim",
"text" : "blublu"
}
],
"tags" : [
"bla",
"blo",
"blu"
]
}
bye
ronald@ronald-cce:~/curso-m101/hw3$ exit
Script concluído, o arquivo é test.log
ronald@ronald-cce:~/curso-m101/hw3$ cat test.log
Script iniciado em Sex 16 Nov 2012 16:19:04 BRT
ronald@ronald-cce:~/curso-m101/hw3$ mongo test
MongoDB shell version: 2.2.1
connecting to: test
> show collections
fruit
posts
system.indexes
test
videos.chunks
videos.files
videos_meta
> db.posts.findOne()
{
"_id" : ObjectId("509df08f27f819ffd9d9ef2d"),
"author" : "Jane",
"content" : "bla bla",
"comments" : [
{
"author" : "John",
"text" : "bloblo"
},
{
"author" : "Jim",
"text" : "blublu"
}
],
"tags" : [
"bla",
"blo",
"blu"
]
}
bye
ronald@ronald-cce:~/curso-m101/hw3$ exit

Script concluído em Sex 16 Nov 2012 16:20:01 BRT
ronald@ronald-cce:~/curso-m101/hw3$ 


It didn't crash and the output is nice because I didn't use any backspace.... Do you have a different version of script or mongo shell ?

Jorge Puente Sarrín

unread,
Nov 16, 2012, 2:33:04 PM11/16/12
to mongod...@googlegroups.com
I see, the issue refers when copy and paste any text with special characteres on mongo shell, then this crashes.

tee is used for IO logging only in this case.

Thanks a lot.


2012/11/16 Ronald Stalder <rona...@gmail.com>

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb



--
Jorge Puente Sarrín.

Ronald Stalder

unread,
Nov 16, 2012, 2:38:30 PM11/16/12
to mongod...@googlegroups.com
Do you have an example of text that crashes ? And is this text utf-8 encoded (as mongo shell doesn't like latin-1 or so)

Jorge Puente Sarrín

unread,
Nov 16, 2012, 2:42:28 PM11/16/12
to mongod...@googlegroups.com
Well,

On Windows, I have tried with this character: ´

And this is the output:

MongoDB shell version: 2.2.0
connecting to: test
> {{
---
Unicode text could not be correctly displayed.
Please change your console font to a Unicode font (e.g. Lucida Console).
---

┬┤
bye

I will communicate with the creator thread for get your example...

Regards.




2012/11/16 Ronald Stalder <rona...@gmail.com>
Do you have an example of text that crashes ? And is this text utf-8 encoded (as mongo shell doesn't like latin-1 or so)

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb



--
Jorge Puente Sarrín.

Jose Calderon-Celis

unread,
Nov 16, 2012, 4:51:16 PM11/16/12
to mongod...@googlegroups.com
Estimado Ronald:
  Apenado, pues no pudo reproducir lo indicado en el video. por favor

abc@aws10:~$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 12.10
Release:    12.10
Codename:    quantal
abc@aws10:~$ tee --version
tee (GNU coreutils) 8.13
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Parker, Richard M. Stallman, and David MacKenzie.

abc@aws10:~/mongo/m102/script$ mongo --shell  week3.js | tee  ronald.log

MongoDB shell version: 2.2.1
connecting to: test
type "help" for help
> >

------------------------------
Dar un <enter> y el prompt lo presenta en la misma linea, <enter> varias veces, y no responde nada, pero registra cada <enter> y lo agrega al proximo comando que se le de.
-----------------------------
> show dbs











NY    0.0625GB
admin    (empty)
advance    0.0625GB
blog    0.0625GB
jcc    0.0625GB
local    (empty)
m101    0.0625GB
mrex    0.0625GB
pcat    0.0625GB
reddit    0.0625GB
school    0.0625GB
test    0.125GB
trouble    0.0625GB
week3    0.0625GB
>

Como ve esto ocurre sin tener que copy/paste, lo del video simplemente use chrome con una web del foro de discusion del curso.

Gracias, por responder

Atentamente

---
Jose Calderon-Celis





2012/11/16 Ronald Stalder <rona...@gmail.com>
Hi Jorge,

in linux (don't know about Mac) you have the script command, but it has the same problem: for input it shows every backspace etc... You'll have to edit the output before copying/pasting
 

--
ronald.log

Jose Calderon-Celis

unread,
Nov 16, 2012, 5:08:31 PM11/16/12
to mongod...@googlegroups.com
Ronald:
   Gracias por tu solucion, trabaja, y no bloquea la entrada del mongo shell.

En el foro del curso jfox (adjunto m102-jfox.tar.gz)  dijo:

mongo --shell week3.js > >(tee ./mongo_tee.log)

">(tee ./mongo_tee.log)" es un tubería nombrada (named pipe en Inglés), así hay un espacio entre los dos ">". Espero que sea útil para usted.

Hm, en realidad eso no es una tubería nombrada, es la sustitución de procesos. Pero funciona, como se llame. :-)


Alguna idea para limpiar el log?

Gracias

---
Jose Calderon-Celis



2012/11/16 Ronald Stalder <rona...@gmail.com>
This is a copy/paste form my console (highlighting manually here in the textbox):
m102-jfox.tar.gz

Ronald Stalder

unread,
Nov 16, 2012, 9:43:09 PM11/16/12
to mongod...@googlegroups.com
Jose,

gostei dessa "tubulação" (??) que não é "named pipe" porque cria um arquivo perfeitamente normal. Ao contrario do script, o echo do input sai correto, mesmo se tiver seta-para-cima, backspace, etc. E é fácil de acompanhar com um tail -f numa outra janela.

Só uma coisa é curiosa: ao dar varias vezes enter no shell, ele mostra só "> >" em vez de subir, mas não bloqueia. Pode entrar um comando, que sai no log (só que depois do comando ele insere uma linha branca para cada enter)

Agora, para limpar o log, eu vejo duas possibilidades:
- /bin/echo -e "-----\n" > mongo_tee.log   (numa outra janela de terminal)
- ou, criar um script "clear_log.sh" com o comando echo acima, e lançar
   >runProgram("clear_shell.sh")
  de dentro do mongo shell

O clear_log.sh daria até para sofisticar, adicionando o arquivo a limpar como parâmetro argv1

Obrigado por esse > >(tee !!
um abraço
Ronald

Jose Calderon-Celis

unread,
Nov 17, 2012, 10:14:34 AM11/17/12
to mongod...@googlegroups.com
Ronald:
   En el video te muestro copy/paste desde una consola, a mongo std y mongo (jfox) con tee.

Por favor trata de repetirlo.

Saludos

Jose Calderon-Celis

unread,
Nov 17, 2012, 10:31:22 AM11/17/12
to mongod...@googlegroups.com
oops, adjunto video

Jose

ronald.tar.gz

Ronald Stalder

unread,
Nov 17, 2012, 10:32:44 AM11/17/12
to mongod...@googlegroups.com
Jose,

qual é o video ?  Eu só achei aquele mongo_tee.ogv no seu post em 'mongodb lima' que mostra que o simples tee não funciona

abraço
Ronald

Ronald Stalder

unread,
Nov 17, 2012, 10:38:14 AM11/17/12
to mongod...@googlegroups.com
ok, recebi o video, estou tentando entender o que passa.. Depois te digo!

abra�o
Ronald

Em 17-11-2012 12:31, Jose Calderon-Celis escreveu:
> oops, adjunto video
>
> Jose

Ronald Stalder

unread,
Nov 17, 2012, 11:31:45 AM11/17/12
to mongod...@googlegroups.com
Jose

eu não consigo reproduzir o problema aqui. Ao lançar mongo test > >(tee tee.log) e colar a função R3, eu consigo edita-la sem problema (seta-para-cima, seta-para-esquerda, etc). Aqui o output to tee.log:

ronald@ronald-cce:~$ cat tee.log

MongoDB shell version: 2.2.1
connecting to: test
> r3   for(var i = 0; i<<values.length; i++){...        total+=parseInt(values[i]);   };






function (key, values) {
    var total = 0;
    for (var i = 0; i << values.length; i++) {
        total += parseInt(values[i]);
    }
    return total;
}
> r3 = function(key, values){    var total = 0;    for(var i = 0; i<values.length; i++){        total+=parseInt(values[i]);    }    return total;   };
function (key, values) {
    var total = 0;
    for (var i = 0; i < values.length; i++) {
        total += parseInt(values[i]);
    }
    return total;
}
> r3
function (key, values) {
    var total = 0;
    for (var i = 0; i < values.length; i++) {
        total += parseInt(values[i]);
    }
    return total;
}
> exit
bye
ronald@ronald-cce:~$

( é a mesma coisa se eu lançar o mongo .. tee diretamente, como acima, ou seu lanço . mb-fox )


Percebi uma coisa: o tee.log só fica bonito com cat, se pegar esse arquivo no less ou no vim, está cheio de caracteres especiais. Será que haja uma diferença entre o terminal do Ubuntu 12.04 e o 12.10?? Você usa o bash em modo emacs ou vi (meu é emacs)? ( O meu mongo shell também é o 2.2.1 )


abraço
Ronald

Reply all
Reply to author
Forward
0 new messages