Zotero commandline, or, How I Learned to Stop Worrying and Love the MozRepl

  1. Got Zotero? Good.
  2. Install MozLab.
  3. Restart Firefox.
  4. Start MozRepl.
  5. Open a terminal.
  6. telnet localhost 4242
  7. Get the Zotero object:

    var zotero = Components.classes["@zotero.org/Zotero;1"] .getService(Components.interfaces.nsISupports)
    .wrappedJSObject;

    ...but all on one line, no spaces before the dots. Sorry, my formatting plugin went b0nkr5.

  8. Surprise your friends, amuse your enemies, bore the big-Zotero-collectionists:

    repl> for each (item in zotero.Items.getAll()) {
    ....> alert(item.getField("title"));
    ....> }

Pretty nifty, eh?

Trackback URL for this post:

http://onebiglibrary.net/trackback/256

variable name

Need a consistent variable name (one of Zotero OR z)

e.g.

var z = ... 

OR

for each (i in Zotero.Items.getAll()) { 

Thanks for the tip, Dan! Going to take a closer look at http://dev.zotero.org/interacting_with_zotero_from_within_firefox now!

Oops - you're right!

Fixing now. Thanks!

If you figure out how to get

If you figure out how to get Firefox/Zotero running on a remote server, that would be very useful.

When you say "running on a

When you say "running on a remote server", what do you mean? Yesterday the folks at the Zotero mothership (CHNM) did a lovely semi-public demo of syncing to their server, so that's coming, for one, and you can see that happen in the 1.5 betas.

Do you want to be able to interact with a Firefox/Zotero running on another machine? If so I think you could do it this way, just ssh over and telnet once you're there. (You wouldn't want to expose the MozRepl port outside a firewall, right?)

Nice!

Very nice, Dan -- thanks for this!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <pre> <code> <img> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <form> <input> <span> <object> <embed> <br>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <apache>, <bash>, <css>, <diff>, <dot>, <java>, <javascript>, <mysql>, <perl>, <php>, <python>, <rails>, <ruby>, <sql>, <xml>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
2 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Syndicate content

This site is Copyright (c) 2005-2008 by Daniel Chudnov. All rights reserved.

All opinions stated here are my own, and do not reflect those of my employer.