0

I have a script shell that is reading from a file. This is the command line text that i would like to run under the bin folder of neo4j

bin/neo4j-import --into /home/micmal/neo4j-community-3.0.1/data/databases/graph_test.db --id-type string --nodes:

I would like to use a script shell to get that command and go to the folder of neo4j and paste it so it runs.

my shell looks like :

#!/bin/bash    
batch_import_value= `cat _batchfile.txt`  
cd /home/neo4j-community-3.0.1/   
echo $batch_import_value`

it doesn't seem work Any idea?

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
ErEcTuS
  • 777
  • 1
  • 14
  • 33
  • http://shellcheck.net/ would have caught this for you without involving humans – Charles Duffy Feb 01 '18 at 17:13
  • ...well, much of it. `echo` doesn't run its arguments as a command, and storing commands inside variables [is an extremely fault-prone practice](http://mywiki.wooledge.org/BashFAQ/050). Why do you distinguish from the script you use and the file storing the command line? -- that is, why aren't you thinking of that file storing the command you want to run *as a script itself*? – Charles Duffy Feb 01 '18 at 17:13
  • Hey Charles, because tha file contains neo4j syntax listed as a long string. ...that i usually copy paste n the bin folder of neo4J – ErEcTuS Feb 01 '18 at 21:30
  • What does that have to do with anything? Do you actually have a *specific technical reason* to copy-and-paste the syntax, rather than to tell your shell to run it by sourcing it in (or starting a new shell to run it, by adding a shebang and invoking it as a script)? If so, please [edit] the question to make that reason clear. – Charles Duffy Feb 01 '18 at 21:37
  • You are right Charles, there was not need to echo it. Thanks! – ErEcTuS Feb 02 '18 at 09:21
  • To be clear, I'd write this as `bf=$PWD/_batchfile.txt; cd /home/neo4j-community-3.0.1 || exit; source "$bf"`. If you're just running `$batch_import_value` as a command, that's quite bug-prone; see [BashFAQ #50](http://mywiki.wooledge.org/BashFAQ/050). – Charles Duffy Feb 02 '18 at 13:56

0 Answers0