title: How to run a cypher script file from Terminal with the cypher-shell neo4j command?
body: <p>I have a cypher script file and I would like to run it directly.</p>
  
  <p>All answers I could find on SO to the best of my knowledge use the command <code>neo4j-shell</code> which in my version (Neo4j server 3.5.5) seems to be deprecated and substituted with the command <code>cyphershell</code>.</p>
  
  <p>Using the command <code>sudo ./neo4j-community-3.5.5/bin/cypher-shell --help</code> I got the following instructions.</p>
  
  <blockquote>
    <p>usage: cypher-shell [-h] [-a ADDRESS] [-u USERNAME] [-p PASSWORD]
    [--encryption {true,false}]
                        [--format {auto,verbose,plain}] [--debug] [--non-interactive] [--sample-rows SAMPLE-ROWS]
                        [--wrap {true,false}] [-v] [--driver-version] [--fail-fast | --fail-at-end] [cypher]</p>
    
    <p>A command line shell  where  you  can  execute  Cypher  against  an 
    instance  of  Neo4j.  By  default the shell is interactive but you can
    use it for scripting by  passing  cypher  directly  on the command
    line or by piping a file with cypher statements (requires Powershell
    on Windows).</p>
  </blockquote>
  
  <p>My file is the following which tries to create a graph from csv files and it comes from the book "Graph Algorithms".</p>
  
  <pre><code>WITH "https://github.com/neo4j-graph-analytics/book/raw/master/data" AS base 
  WITH base + "transport-nodes.csv" AS uri
  LOAD CSV WITH HEADERS FROM uri AS row
  MERGE (place:Place {id:row.id})
  SET place.latitude = toFloat(row.latitude),
    place.longitude = toFloat(row.latitude),
    place.population = toInteger(row.population)
  
  WITH "https://github.com/neo4j-graph-analytics/book/raw/master/data/" AS base 
  WITH base + "transport-relationships.csv" AS uri
  LOAD CSV WITH HEADERS FROM uri AS row
  MATCH (origin:Place {id: row.src})
  MATCH (destination:Place {id: row.dst})
  MERGE (origin)-[:EROAD {distance: toInteger(row.cost)}]-&gt;(destination)
  </code></pre>
  
  <p>When I try to pass the file directly with the command:</p>
  
  <pre><code>sudo ./neo4j-community-3.5.5/bin/cypher-shell neo_4.cypher
  </code></pre>
  
  <p>first it asks for username and password but after typing the correct password (the wrong password results in the error <code>The client is unauthorized due to authentication failure.</code>) I get the error:</p>
  
  <pre><code>Invalid input 'n': expected &lt;init&gt; (line 1, column 1 (offset: 0))
  "neo_4.cypher"
   ^
  </code></pre>
  
  <p>When I try piping with the command:</p>
  
  <pre><code> sudo cat neo_4.cypher| sudo ./neo4j-community-3.5.5/bin/cypher-shell -u usr -p 'pwd'
  </code></pre>
  
  <p>no output is generated and no graph either.</p>
  
  <p>How to run a cypher script file with the neo4j command <code>cypher-shell</code>?</p>