通过shell脚本运行后写入数据库控制台



我正试图编写一个脚本,将运行OrientDB shell,然后通过适当的命令和凭据连接。但是,在运行控制台后,我无法获得任何文本。

#!/bin/bash
(cd ../libs/orientdb-community-1.7.4/bin && source console.sh) && echo "CONNECT remote:localhost/pumpup root test"

这是我得到的:

gsquare567@Macintosh ~/S/p/s/scripts> ./db_console.sh
OrientDB console v.1.7.4 (build UNKNOWN@r; 2014-06-23 19:29:10+0200) www.orientechnologies.com
Type 'help' to display all the commands supported.
Installing extensions for GREMLIN language v.2.5.0
orientdb>

手动输入命令后,它应该这样做:

orientdb> CONNECT remote:localhost/pumpup root test
Connecting to database [remote:localhost/pumpup] with user 'root'...OK
orientdb {pumpup}>

如何在新的控制台中运行echo ed命令?

对于OrientDB 2.0-SNAPSHOT,您还可以启用echo:

(cd ../libs/orientdb-community-1.7.4/bin && source console.sh) && echo "set echo true;CONNECT remote:localhost/pumpup root test"

Echo将字符串打印到标准输出中,但不传递给命令。

Console支持file name作为参数,因此您可以将SQL脚本写入文件中,然后运行:

./console.sh script.sql

最新更新