You are on page 1of 4

18/11/2017 sdk/README.

md at master meganz/sdk GitHub

meganz / sdk

Branch: master sdk / examples / megacmd / README.md Find file Copy path

polmr improved changelog scripts f6b3c49 on 28 Aug

1 contributor

200 lines (149 sloc) 7.84 KB

MEGAcmd - Command Line Interactive and Scriptable


Application
MEGAcmd provides non UI access to MEGA services. It intends to offer all the functionality with your MEGA account via
commands.

Available packages for MEGAcmd in all supported platforms should be found here.

It supports 2 modes of interaction:

interactive. A shell to query your actions


scriptable. A way to execute commands from a shell/a script/another program.

In order to provide those 2 modes, it features one server (MEGAcmdServer), an interactive shell (MEGAcmdShell) and several
commands that will launch the non-interactive client (MEGAcmdClient). See Usage and Platform to understand how to use it
in your particular system.

Building MEGAcmd
If you wish to build MEGAcmd using this repository, here are a list of requirements and building instructions.

Requirements
The same as those for the sdk ( cryptopp, zlib, sqlite3, cares, libuv, ssl, curl, sodium ) and of course readline .
Also, it is recommended to include pcre to have support for regular expressions.

For convenience here is a list of packages for ubuntu 16.04: autoconf libtool g++ libcrypto++-dev libz-dev sqlite3-
dev libsqlite3-dev libssl-dev libcurl4-openssl-dev libreadline-dev libpcre++-dev libsodium-dev

Building and installing

For platforms with Autotools, MEGAcmd is included in the generic compilation of the sdk. To build and install:

sh autogen.sh
./configure
make
make install

You will need to run make install as root

To disable MEGAcmd use configure with --disable-megacmd

Note : if you use a prefix in configure, autocompletion from non-interactive usage won't work. You would need to source
/YOUR/PREFIX/etc/bash_completion.d/megacmd_completion.sh (or link it at /etc/bash_completion.d)

Usage

https://github.com/meganz/sdk/blob/master/examples/megacmd/README.md 1/4
18/11/2017 sdk/README.md at master meganz/sdk GitHub
Before explaining the two ways of interaction, it is important to understand how MEGAcmd works. When you login with
MEGAcmd, your session, the list of synced folders, and some cache database are stored in your local home folder. MEGAcmd
also stores some other configuration in that folder. Closing it does not delete those and restarting your computer will restore
your previous session (the same as megasync won't ask for user/password once you restart your computer). You will need to
logout properly in order to clean your data.

Now let's get into details of the two usage modes. Both modes require that MEGAcmdServer is running. You can manually
launch it. Fortunately, you can also open the interactive shell or execute any command and the server will start automatically.

Interactively:
Execute MEGAcmd shell. Platform section explains how to do that in the different supported systems. You should be facing an
interactive shell where you can start typing your commands, with their arguments and flags. You can list all the available
commands with help . And obtain useful information about a command with command --help

Primero, desea iniciar sesin en su cuenta. De nuevo: observe que al hacer esto, almacena la sesin y otras cosas en su carpeta
de inicio. Se requiere un cierre de sesin completo si desea terminar su sesin de forma permanente y limpiar cualquier rastro
(consulte logout --help para obtener ms informacin).

No interactivamente:
Cuando el servidor MEGAcmd se est ejecutando, escuchar los comandos del cliente. Usa los diferentes mega-* comandos
disponibles. mega-help listar todos estos comandos (deber anteponer "mega-" a los comandos all enumerados). Para
obtener ms informacin, use mega-command --help

Esos comandos tendrn un valor de salida! = 0 en caso de falla. Consulte megacmd.h para ver los cdigos de error existentes.

Idealmente, le gustara tener estos comandos en su RUTA (Consulte Platform para obtener ms informacin). Para ms
informacin, use mega-help --non-interactive .

Plataformas

Linux
Si ha instalado MEGAcmd usando uno de los paquetes disponibles aqu , o lo ha construido sin l --prefix , tanto el servidor (
mega-cmd-server ), el shell ( mega-cmd ) y los diferentes comandos del cliente ( mega-* ) estarn en su RUTA (en una
instalacin nueva, es posible que necesita abrir su terminal nuevamente). Si est utilizando bash, tambin debe tener
autocompletado para que los comandos del cliente funcionen. Si ese no es tu caso, incluye la ubicacin de los binarios en tu
camino.

Windows
Una vez que haya instalado MEGAcmd, solo necesita ejecutar el ejecutable principal para abrir el shell. Esto abrir una segunda
ventana con MEGAcmdServer. Tenga en cuenta que esta ventana comenzar a minimizarse. Para una mejor experiencia de
usuario (especialmente en WINDOWS 7), recomendamos ejecutar MEGAcmd desde PowerShell: Open PowerShell y ejecutar:

$env:PATH += ";$env:LOCALAPPDATA\MEGAcmd"
MEGAcmdShell

Para el uso no interactivo, hay varios mega-*.bat comandos de cliente que puede usar para escribir sus rutas absolutas, o
incluir su ubicacin en su PATH de entorno y ejecutarlas normalmente ( mega-* ). Si usa PowerShell y ha instalado el MEGAcmd
oficial, puede hacerlo simplemente con:

$env:PATH += ";$env:LOCALAPPDATA\MEGAcmd"

La finalizacin de los comandos del cliente requiere bash, por lo tanto, no est disponible para Windows.

Advertencias

https://github.com/meganz/sdk/blob/master/examples/megacmd/README.md 2/4
18/11/2017 sdk/README.md at master meganz/sdk GitHub
Aunque ha habido varios esfuerzos para tener caracteres Unicode no ASCII compatibles con Windows, an puede haber algunos
problemas. Preste especial atencin si est dispuesto a usar tuberas o enva la salida de un comando a un archivo desde los
comandos de su cliente. Consulte help --unicode para obtener ms informacin al respecto.

Mac OS
Para MacOS, despus de instalar dmg, puede iniciar el servidor usando MEGAcmd en Aplicaciones. Si desea utilizar los
comandos del cliente desde la Terminal de MacOS, abra la Terminal e incluya la carpeta de instalacin en la RUTA. Tpicamente:

export PATH=/Applications/MEGAcmd.app/Contents/MacOS:$PATH

Y para completar bash, fuente megacmd_completion.sh :

source /Applications/MEGAcmd.app/Contents/MacOS/megacmd_completion.sh

caracteristicas:

Autocompletado:
MEGAcmd presenta autocompletado en modo interactivo y no interactivo (solo para bash). Ayudar a completar archivos locales
y remotos (Mega Cloud), indicadores para comandos, valores para banderas / niveles de acceso, incluso contactos.

Verbosidad
Hay dos tipos diferentes de mensajes de registro:

Basado en SDK: los mensajes informados por el SDK y las bibliotecas dependientes.
Basado en MEGAcmd: esos mensajes informados por MEGAcmd.

Puede ajustar el nivel de registro para esos tipos con log comando. Sin embargo, para los comandos no interactivos, pasando
-v ( -vv , -vvv y as sucesivamente para una salida con ms informacin) utilizar un mayor nivel de verbosidad a un
comando especfico.

Expresiones regulares
Si ha compilado MEGAcmd con PCRE (habilitado por defecto), puede usar expresiones compatibles con PCRE en ciertos
comandos con la bandera --use-pcre . De lo contrario, si se compila con c ++ 11, se usarn las expresiones regulares c ++ 11.
Si no es el caso anterior, solo puede usar comodines: "*" para cualquier nmero de caracteres o "?" para un solo personaje
desconocido. Puede verificar la compatibilidad de expresiones regulares con find --help . p.ej:

find --help
...
Options:
--pattern=PATTERN Pattern to match (Perl Compatible Regular Expressions)

Notice: if you use MEGAcmd in non interactive mode, notice that shell pattern will take precedence. You will need to either
escape symbols like * ( \* ) or surround them between quotes (e.g: "*.txt")

Known Bugs
Currently there are certain discrepancies with PATHS when loggin into a public folder. For instance, imagine a folder named
toshare with a subfolder named x . If we login into toshare and execute find /x , this will be the output:

/toshare/x

Whereas if we execute find /toshare/x , we receive an error, since folder absolute path refers to / as root path.

https://github.com/meganz/sdk/blob/master/examples/megacmd/README.md 3/4
18/11/2017 sdk/README.md at master meganz/sdk GitHub

[err: 12:21:51] Couldn't find /toshare/x

It might better be referred as /toshare/x

https://github.com/meganz/sdk/blob/master/examples/megacmd/README.md 4/4

You might also like