/usr/bin/mnemo-import-text-note is in php-horde-mnemo 4.2.12-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/usr/bin/php
<?php
/**
* This script imports plain text data into Mnemo notepads.
*
* The data is read from standard input, the notepad and user name passed as
* parameters.
*
* Copyright 2005-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/apache.
*
* @author Jan Schneider <jan@horde.org>
*/
if (file_exists(__DIR__ . '/../../mnemo/lib/Application.php')) {
$baseDir = __DIR__ . '/../';
} else {
require_once 'PEAR/Config.php';
$baseDir = PEAR_Config::singleton()
->get('horde_dir', null, 'pear.horde.org') . '/mnemo/';
}
require_once $baseDir . 'lib/Application.php';
Horde_Registry::appInit('mnemo', array('cli' => true));
// Read command line parameters.
if (count($argv) != 4) {
$cli->message('Too many or too few parameters.', 'cli.error');
usage();
}
$notepad = $argv[1];
$user = $argv[2];
$file = $argv[3];
// Read standard input.
if (!file_exists($file)) {
$cli>message("$file does not exist", 'cli.error');
usage();
}
$data = file_get_contents($file);
if (empty($data)) {
$cli->message('No import data provided.', 'cli.error');
usage();
}
$data = pathinfo($file, PATHINFO_FILENAME) . "\n\n" . $data;
// Set user.
$registry->setAuth($user, array());
// Import data.
try {
$result = $registry->notes->import($data, 'text/plain', $notepad);
$cli->message('Imported successfully ' . count($result) . ' notes', 'cli.success');
} catch (Mnemo_Exception $e) {
$cli->fatal($e->getMessage());
}
function usage()
{
$GLOBALS['cli']->writeln('Usage: mnemo-import-text-note notepad user file');
exit;
}
|