PA_Commons
PA_Commons

Reputation: 269

Cassandra cql shell script

I'm having an issue with a simple script here. Just can't find documented help that resolves my issue.

Here is my script.

#!/bin/bash 

$VCOPS_BASE/cassandra/apache-cassandra-2.1.8/bin/cqlsh --ssl --cqlshrc  $VCOPS_BASE/user/conf/cassandra/cqlshrc 

-e "cql_statement;"

I left out the cql for simplicity's sake, but everytime I run my file from the command line I simply enter the cql shell.

--execute and echo don't work either and I'm really not sure why I would need to save the cql statement to another file.

Any help would be appreciated.

Upvotes: 4

Views: 5149

Answers (1)

Aaron
Aaron

Reputation: 57748

That's because -e is a cqlsh option, not a bash command that stands on its own. Therefore, it needs to be on the same line as your cqlsh command.

#!/bin/bash 

$VCOPS_BASE/cassandra/apache-cassandra-2.1.8/bin/cqlsh --ssl --cqlshrc $VCOPS_BASE/user/conf/cassandra/cqlshrc -e "cql_statement;"

I tested this out with a simpler version:

aploetz@dockingBay94:~/scripts$ cat getEmail.sh
#!/bin/bash

cqlsh -u cassandra -p cassandra -e "SELECT * FROm stackoverflow.users_by_email WHERe email='[email protected]';"

aploetz@dockingBay94:~/scripts$ ./getEmail.sh 

 email                  | id                                   | username
------------------------+--------------------------------------+----------
 [email protected] | d8e57eb4-c837-4bd7-9fd7-855497861faf |      Mal

(1 rows)
aploetz@dockingBay94:~/scripts$

Upvotes: 4

Related Questions