I want to use the Neo4j shell. With the V1.9 release, it was in the bin folder of the installation, but since I upgraded to v2.0.0-M06, I can no longer find it. The bin folder only contains the following files ...
Directory of C:\Program Files\Neo4j Community\bin
16/10/2013 15:38 <DIR> .
16/10/2013 15:38 <DIR> ..
16/10/2013 15:38 37 neo4j-community-user-vmoptions.loc
14/10/2013 09:38 491,016 neo4j-community.exe
16/10/2013 15:38 242 neo4j-community.vmoptions
14/10/2013 09:37 39,564,808 neo4j-desktop-2.0.0-M06.jar
4 File(s) 40,056,103 bytes
2 Dir(s) 16,272,773,120 bytes free
I know I can use the shell in the web UI, but I want to pipe input and output, and I can't figure how to do that except with the stand-alone shell. Any ideas?
I have found the answer - in another question - How to install Neo4j 2.0+ as a windows service .
By downloading the zip file rather than the windows installer, I get all the .bat files, including Neo4jshell.bat. Problem solved!
Try this:
cd C:\Program Files\Neo4j Community
jre\bin\java -cp bin\neo4j-desktop-1.9.4.jar org.neo4j.shell.StartClient [--file /your/file/of/stuff.cyp]
Related
I have hundreds of files in a directory that I would like to count the occurrence of a string in each file.
I would like the output to be a summary file that contains the original file name plus the count (ideally on the same line)
for example
file1 6
file2 3
file3 4
etc
Thanks for your consideration
CAUTION: I am pretty much an enthusiastic amateur, so take everything with a grain of salt.
Several questions for you - depending on your answers, the solution below may need some adjustments.
Are all your files in the same directory, or do you also need to look through subdirectories and sub-subdirectories, etc.? Below I make the simplest assumption - that all your files are in a single directory.
Are all your files text files? In the example below, the directory will contain text files, executable files, symbolic links, and directories; the count will only be given for text files. (What linux believe to be text files, anyway.)
There may be files that do not contain the searched-for string at all. Those are not included in the output below. Do you need to show them too, with a count of 0?
I assume by "count occurrences" you mean all of them - even if the string appears more than once on the same line. (Which is why a simple grep -c won't cut it, as that only counts lines that contain the substring, no matter how many times each.)
Do you need to include hidden files (whose name begins with a period)? In my code below I assumed you don't.
Do you care that the count appears first, and then the file name?
OK, so here goes.
[oracle#localhost test]$ ls -al
total 20
drwxr-xr-x. 3 oracle oinstall 81 Apr 3 18:42 .
drwx------. 39 oracle oinstall 4096 Apr 3 18:42 ..
-rw-r--r--. 1 oracle oinstall 40 Apr 3 17:44 aa
lrwxrwxrwx. 1 oracle oinstall 2 Apr 3 18:04 bb -> aa
drwxr-xr-x. 2 oracle oinstall 6 Apr 3 17:40 d1
-rw-r--r--. 1 oracle oinstall 38 Apr 3 17:56 f1
-rw-r--r--. 1 oracle oinstall 0 Apr 3 17:56 f2
-rwxr-xr-x. 1 oracle oinstall 123 Apr 3 18:15 zfgrep
-rw-r--r--. 1 oracle oinstall 15 Apr 3 18:42 .zz
Here's the command to count 'waca' in the text files in this directory (not recursive). I define a variable substr to hold the desired string. (Note that it could also be a regular expression, more generally - but I didn't test that so you will have to, if that's your use case.)
[oracle#localhost test]$ substr=waca
[oracle#localhost test]$ find . -maxdepth 1 -type f \
> -exec grep -osHI "$substr" {} \; | sed "s/^\.\/\(.*\):$substr$/\1/" | uniq -c
8 aa
2 f1
1 .zz
Explanation: I use find to find just the files in the current directory (excluding directories, links, and whatever other trash I may have in the directory). This will include the hidden files, and it will include binary files, not just text. In this example I find in the current directory, but you can use any path instead of . I limit the depth to 1, so the command only applies to files in the current directory - the search is not recursive. Then I pass the results to grep. -o means find all matches (even if multiple matches per line of text) and show each match on a separate line. -s is for silent mode (just in case grep thinks of printing messages), -H is to include file names (even when there is only one file matching the substring), and -I is to ignore binary files.
Then I pass this to sed so that from each row output by grep I keep just the file name, without the leading ./ and without the trailing :waca. This step may not be necessary - if you don't mind the output like this:
8 ./aa:waca
2 ./f1:waca
1 ./.zz:waca
Then I pass the output to uniq -c to get the counts.
You can then redirect the output to a file, if that's what you need. (Left as a trivial exercise - since I forgot that was part of the requirement, sorry.)
Thanks for the detailed answer it provides me with ideas for future projects.
In my case the files were all the same format (output from another script) and the only files in the directory.
I found the answer in another thread
grep -c -R 'xxx'
On OpenWRT, I have a Lua script on_new_device.lua that runs fine if I execute lua on_new_device.lua; however, I'd like to run it simply by executing ./on_new_device.lua.
Executing ./on_new_device.lua returns this error...
root#router:~# ./on_new_device.lua
-ash: ./on_new_device.lua: not found
The file has execute permissions...
root#router:~# ls -la ./on_new_device.lua
-rwxrwxrwx 1 root root 1094 Jun 18 11:06 ./on_new_device.lua
The file starts with #!/usr/bin/lua...
root#router:~# head -1 ./on_new_device.lua
#!/usr/bin/lua
How can I execute this file directly?
Can you wrap it in a script?
Copy this into a test.ash file:
#!/bin/ash
/usr/bin/lua /[path]/on_new_device.lua
Then chmod 755 on test.ash, and then you can run:
./test.ash
Bah, the problem was that the lua script was created on a Windows machine and had \r\n line endings. Saving the file with \n line endings solved the issue.
Command CALL dbms.procedures() shows the standard 25 dbms procedures, cannot see APOC procedures. Any call to these procedures outputs an error saying that it cannot find it and to check spelling, etc.
Neo4j Community 3.2.5
Added apoc-3.2.3.5-all.jar fils in /plugins folder as listed in start prompt below:
Active database: cnaf_v1_20171218.db
Directories in use:
home: /data/neo4j/neo4j-community-3.2.5
config: /data/neo4j/neo4j-community-3.2.5/conf
logs: /data/neo4j/neo4j-community-3.2.5/logs
plugins: /data/neo4j/neo4j-community-3.2.5/plugins
import: /data/neo4j/neo4j-community-3.2.5/import
data: /data/neo4j/neo4j-community-3.2.5/data
certificates: /data/neo4j/neo4j-community-3.2.5/certificates
run: /data/neo4j/neo4j-community-3.2.5/run
Starting Neo4j.
Started neo4j (pid 44178). It is available at ... There may be a short delay until the server is ready.
See /data/neo4j/neo4j-community-3.2.5/logs/neo4j.log for current status.
Relevant conf/neo4j.conf file settings:
# The name of the database to mount
dbms.active_database=cnaf_v1_20171218.db
# Paths of directories in the installation.
dbms.directories.plugins=plugins
# added these based on other stack overflow APOC-based posts
dbms.security.procedures.unrestricted=apoc.*
apoc.export.file.enabled=true
Other:
$ ls -al plugins/
total 7104
drwxr-xr-x 2 neo4j neo4j 34 Jan 17 14:04 .
drwxr-xr-x 11 neo4j neo4j 4096 Jan 17 15:22 ..
-rwxrwxrwx 1 neo4j neo4j 7270364 Jan 17 14:06 apoc-3.2.3.5-all.jar
I have the following in ./bash_profile
export SRCROOT=/users/benjamin.beasley/work/svn/ccdev
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk_dev/Contents/Home
export PATH=$PATH$:~/tools/tools-versions/gradle-2.2.1/bin
export PATH=$PATH$:~/tools/activator
In ~/tools/tools-versions/gradle-1.12/bin, I do
drwxr-xr-x# 4 xxx.xxx WORKDAYINTERNAL\Domain Users 136 Nov 12 11:47 .
drwxr-xr-x# 13 xxx.xxx WORKDAYINTERNAL\Domain Users 442 Apr 29 2014 ..
-rwxr-xr-x# 1 xxx.xxx WORKDAYINTERNAL\Domain Users 5071 Apr 29 2014 gradle
-rwxr-xr-x# 1 xxx.xxx WORKDAYINTERNAL\Domain Users 2395 Apr 29 2014 gradle.bat
echo $PATH$:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin$:/Users/xxx.xxx/tools/tools-versions/gradle-2.2.1/bin$:/Users/xxx.xxx/tools/activator90566
so I get the gradle executable which is executable. I can execute it from this directory. But if I start a new shell, and type "gradle" it says command not found. But I "echo $PATH$" and I see that the full canonical path to the ~/tools/tools-versions/gradle-2.2.1/bin folder is there.
However I can execute activator which is an executable in the ~/tools/activator directory. I have no clue why bash knows about activator and not gradle.
In summary:
gradle is executable by this user
gradle can be run from the command line.
gradle is in the $PATH$ environment variable
other programs such as activator, which are also in $Path$ are executable anywhere in terminal regardless of directory which is what I want to be true of gradle.
Unix environment variables are $PATH not $PATH$ (they aren't like Windows env vars).
This is causing your problem.
This path is busted: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin$:/Users/xxx.xxx/tools/tools-versions/gradle-2.2.1/bin$:/Users/xxx.xxx/tools/activator90566
Notice the 90566 at the end? That's from $$ having been expanded to the current process id when you set the variable.
None of these are paths that actually exist or work:
/opt/X11/bin$
/Users/xxx.xxx/tools/tools-versions/gradle-2.2.1/bin$
/Users/xxx.xxx/tools/activator90566
As you can see below, %AppData%\npm is added in the system Path variable. I've also tried adding it to the User Path variable. The file grunt.cmd exists in the directory, but only works if I specify it with an absolute path. AKA, path does not work.
C:\Users\TeamCity>echo %path%
%AppData%\npm;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows
\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\10
0\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program F
iles\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Ser
ver\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Ser
ver\100\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program
Files\nodejs\
C:\Users\TeamCity>dir %appdata%\npm
Volume in drive C has no label.
Volume Serial Number is B845-1135
Directory of C:\Users\TeamCity\AppData\Roaming\npm
05/29/2013 03:14 AM <DIR> .
05/29/2013 03:14 AM <DIR> ..
05/29/2013 03:14 AM 298 grunt
05/29/2013 03:14 AM 159 grunt.cmd
05/29/2013 03:13 AM <DIR> node_modules
2 File(s) 457 bytes
3 Dir(s) 23,690,498,048 bytes free
C:\Users\TeamCity>grunt
'grunt' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\TeamCity>%appdata%\npm\grunt
grunt-cli: The grunt command line interface. (v0.1.9)
Running on:
Windows Server 2008 R2 Datacenter
Service Pack 1
64-bit
I don't think you can defer variable expansion in the path. What's in the path is used as is, it doesn't get re-interpreted during a search.
In fact, you must have worked really hard to get that in as %AppData% since you would need to do something like:
path=^%AppData^%\npm;%path%
If you were to just use:
path=%AppData%\npm;%path%
you'd find the actual path would be substituted, so that the path becomes:
C:\Users\TeamCity\AppData\Roaming\npm;C:\Windows\system32; ...
Interestingly enough, a last-ditch effort of "turning it off and on again" actually worked. Alternatively, you can copy the whole path after you added it and type in cmd:
> SET PATH=
and paste your path.