# Cypher script execution error

**URL:** <https://community.neo4j.com/t/cypher-script-execution-error/8049>\
**Category:** Cypher\
**Tags:** cypher\
**Created:** [June 13, 2019, 8:19pm UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049 "2019-06-13T20:19:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![deerajtech](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/deerajtech/32/5230_2.png) [@deerajtech](https://community.neo4j.com/u/deerajtech)\
**Post date:** [June 13, 2019, 8:19pm UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049/1 "2019-06-13T20:19:54Z")

</div>

getting error while trying to run below cyper script  
neo4j\> cypher-shell -file /var/lib/neo4j/import/testscript.cql;

Invalid input '-': expected (line 2, column 1 (offset: 7))  
"-shell -file /var/lib/neo4j/import/testscript.cql;"

Where should we place the cypher scripts(.cql) to execute them? and what is wrong with the above command?

Appreciate your help!.

Thanks,

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [June 13, 2019, 9:17pm UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049/2 "2019-06-13T21:17:33Z")

</div>

it looks like you started cypher-shell, and thus the prompt of

neo4j\>

but then at this prompt you entered

```auto
cypher-shell -file /var/lib/neo4j/import/testscript.cql;

```

After starting cypher-shell and getting to the `neo4j>` prompt the only thing you can do is enter cypher statements. If you want to call cypher-shell and process the contents of a file, and the contents of said file contain a number of cypher statements then this would be accomplished by running

```auto
cat <filename with cypher statements> | <command to start cypher-shell>

```

and thus for your example

```auto
cat /var/lib/neo4j/import/testscript.cql | cypher-shell

```

---

<div class="post-metadata">

**Author:** ![deerajtech](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/deerajtech/32/5230_2.png) [@deerajtech](https://community.neo4j.com/u/deerajtech)\
**Post date:** [June 14, 2019, 1:20am UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049/3 "2019-06-14T01:20:06Z")

</div>

![cypher%20error](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/a/a9df1a9984f29cf6a4266ec623d94781e94711fd.jpeg)

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [June 14, 2019, 2:46pm UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049/4 "2019-06-14T14:46:54Z")

</div>

what happens when you run

```auto
cat /var/lib/neo4j/import/testscript.cql | cypher-shell

```

---

<div class="post-metadata">

**Author:** ![deerajtech](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/deerajtech/32/5230_2.png) [@deerajtech](https://community.neo4j.com/u/deerajtech)\
**Post date:** [June 14, 2019, 2:47pm UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049/5 "2019-06-14T14:47:12Z")

</div>

Thank you Dana.  
Tried your recommendation but still getting an error. Please see attached screenshot.

Thanks,

 ![cypher%20error1](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/c/cfb9f19cbb3f1d37c84d010cf223e8f944362c62.jpeg)

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [June 14, 2019, 5:14pm UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049/6 "2019-06-14T17:14:34Z")

</div>

do not run the `cat /var/lib/neo4j/import/testscript.cql | cypher-shell` when logged into cypher-shell

from the linux prompt, simply run

```auto
cat /var/lib/neo4j/import/testscript.cql | cypher-shell

```

---

<div class="post-metadata">

**Author:** ![deerajtech](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/deerajtech/32/5230_2.png) [@deerajtech](https://community.neo4j.com/u/deerajtech)\
**Post date:** [June 14, 2019, 5:22pm UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049/7 "2019-06-14T17:22:10Z")

</div>

Thank you.  
Here is the output.

ubuntu@ubuntu:/var/lib/neo4j$ cat /var/lib/neo4j/import/testscript.cql | cypher-shell  
The client is unauthorized due to authentication failure.

Thanks,

---

<div class="post-metadata">

**Author:** ![deerajtech](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/deerajtech/32/5230_2.png) [@deerajtech](https://community.neo4j.com/u/deerajtech)\
**Post date:** [June 14, 2019, 5:25pm UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049/8 "2019-06-14T17:25:02Z")

</div>

script ran as below  
ubuntu@ubuntu:/var/lib/neo4j$ cat /var/lib/neo4j/import/testscript.cql | cypher-shell -u xxxxx -p xxxxx

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [June 14, 2019, 6:42pm UTC](https://community.neo4j.com/t/cypher-script-execution-error/8049/9 "2019-06-14T18:42:58Z")

</div>

great to know it works  
also for reference if you define environment variable NEO4J\_USER and NEO4J\_PASSWORD, for example

```auto
export NEO4J_USER=neo4j
export NEO4J_PASSWORD=password

```

and replacing `neo4j` and `password` above with the respective values for your implementation then they will be used for -u and -p when running cypher-shell. Thus if you run

```auto
export NEO4J_USER=neo4j
export NEO4J_PASSWORD=password
cat /var/lib/neo4j/import/testscript.cql | cypher-shell 

```

then it will run the contents of /var/lib/neo4j/import/testscript.cql through a cypher-shell connection and authenticate with the values specified by NEO4J\_USER and NEO4J\_PASSWORD
