How to run shell scripts in neo4j enterprise

Hello, everyone, I am doing the neo4j admin course and I am stuck on exercise #6 "Scripting changes to the database" I have run into issues with the scripts I have created as they are not running the commands. I am using a UNIX system and using relative paths to locate the scripts

my AddConstraints.cypher script is as follows:

</>
#!/bin/bash
cat ./AddConstraints.cypher | ./../../bin/cypher-shell -u neo4j -p training-helps --format verbose
</>

my AddConstraints.sh script is as follows:

</>
#!/bin/bash
cat ./AddConstraints.cypher | ../../bin/cypher-shell -u neo4j -p training-helps --format verbose
</>

my MaintainDB.sh script is as follows:

</>
#!/bin/bash
rm -rf ./MaintainDB.log
./AddConstraints.sh 2>&1 >> ./MaintainDB.log
</>

my MaintainDB.log script is just an empty file I made from text editor without a hash bang at the top

Your AddConstraints.cypher should be a file which contains nothing but cypher statement(s) whereby each statement is terminated by a ;

thanks I have made the changes but I am getting the following error from the terminal when I try to run MaintainDB.sh:

Invalid input '#': expected (line 1, column 1 (offset: 0))

"#!/bin/bash"

^

what is the content of MaintainDB.sh?

how are you invoking?

the contents of the MaintainDB.sh are as follows;
</>
#!/bin/bash
rm -rf ./MaintainDB.log
./AddConstraints.sh 2>&1 >> ./MaintainDB.log
</>

I am calling it via the terminal in its folder by using " sudo ./MaintainDB.sh"

i suspect this is a pure linux error and not so much a Neo4j error

if you run

sudo bash -x ./MaintainDB.sh

to which the inclusion of bash -x should echo every line that is called in the script does this provide more details as to the line causing failure

I am using a Mac/Unix... I am not using a Linux machine

sorry I do not have/use Mac/Unix.
Does
sudo bash -x ./MaintainDB.sh

result in failure? if so what is the error message?

</>
rm -rf ./MaintainDB.log

  • ./AddConstraints.sh

Invalid input '#': expected (line 1, column 1 (offset: 0))

"#!/bin/bash"

</>

is the error message

That's the result when running with 'bash -x' per my last update ????

Are you able to run any shell scripts successfully. This doesn't feel like a Neo4j problem. More like a general OS/scripting issue ?

yes that's the result of running "sudo bash -x ./MaintainDB.sh"

yes I can run some shell scripts it seems only those which have echo commands as their content

And for the working shell scripts is line 1 defined as

#!/bin/bash

??

yes for example the ListProcedures.sh script has the following as its contents and its working perfectly fine:
</>
#!/bin/bash
echo "CALL dbms.procedures() YIELD name;" | ../../bin/cypher-shell -u neo4j -p abcd123 --format plain > ./Procedures.txt

</>