npm package's binary accessible until I add flags - macos

I'm on a mac am trying to install elasticdump. It is also worth noting that I am using zsh, but am getting the equivalent error described below when switching over to bash.
I just re-installed npm from scratch and am now using 6.12.0. After this, I ran npm install elasticdump -g which appears to have worked just fine.
$ which elasticdump
/usr/local/bin/elasticdump
It appears I am still having the same issue I was having before I tried re-installing everything.
I can run elasticdump directly with no issues. It tells me I need an input and an output as I would expect.
$ elasticdump
Sat, 09 Nov 2019 04:52:40 GMT | Error Emitted => {"errors":["`input` is a required input","`output` is a required input"]}
I can even run it with --help.
$ elasticdump --help
elasticdump: Import and export tools for elasticsearch
version: 6.15.7
...
But when I add an input and output, things fall apart!
$ elasticdump \
--input /Users/slant/Desktop/data.json \
--output http://localhost:9200/companies \
--type data
zsh: command not found: elasticdump
And in bash:
$ elasticdump \
> --input /Users/slant/Desktop/data.json \
> --output http://localhost:9200/companies \
> --type data
bash: elasticdump : command not found
I'm completely baffled as to how adding specific flags causes it to become completely inaccessible! Any help at all would be greatly appreciated.
Edit: In case anyone requests this:
$ ls -la /usr/local/bin/elasticdump
lrwxr-xr-x 1 slant admin 47 Oct 1 20:42 /usr/local/bin/elasticdump -> ../lib/node_modules/elasticdump/bin/elasticdump
Accessing the binary through the file directly behaves exactly the same way as using just elasticdump by itself.
Updated, for clarification.
/usr/local/lib/node_modules/elasticdump/bin/elasticdump
Sat, 09 Nov 2019 18:40:56 GMT | Error Emitted => {"errors":["`input` is a required input","`output` is a required input"]}
$ /usr/local/lib/node_modules/elasticdump/bin/elasticdump \
--input /Users/ryan/Desktop/data.json \
--output http://localhost:9200/companies \
--type data
zsh: no such file or directory: /usr/local/lib/node_modules/elasticdump/bin/elasticdump

Related

Makefile execution: permission denied

I've got a quite strange problem with golang and Makefile (on Fedora 33).
My Makefile contains:
run:
go run main.go
which should only print "Hello" to the console. When I run make run I get this error:
go run main.go
make: go: Permission denied
make: *** [Makefile:5: run] Error 127
However, if I change my Makefile to
run:
/usr/bin/go run main.go
it works just fine!
INFO
Outputs of:
$ which go
/usr/bin/go
$ go version
go version go1.15.5 linux/amd64
$ uname -a
Linux localhost.localdomain 5.9.10-200.fc33.x86_64 #1 SMP Mon Nov 23 18:12:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Can someone help me with this? If you need more info please tell me!
Thank you!
EDIT
Console
$ echo ${PATH}
/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/home/olena/bin:/usr/local/sbin:/usr/sbin:/var/lib/snapd/snap/bin
Output of make
echo /usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/home/olena/bin:/usr/local/sbin:/usr/sbin:/var/lib/snapd/snap/bin
/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/home/olena/bin:/usr/local/sbin:/usr/sbin:/var/lib/snapd/snap/bin
go run main.go
make: go: Permission denied
make: *** [Makefile:6: run] Error 127
In /usr/bin
$ ll | grep go
lrwxrwxrwx. 1 root root 20 Nov 14 09:32 go -> /etc/alternatives/go
In /etc/alternatives
$ ll | grep go
lrwxrwxrwx. 1 root root 22 Nov 29 15:16 go -> /usr/lib/golang/bin/go
I ran to the same issue as yours and finally figured out what was wrong with mine. Maybe this works for you, especially if you use zsh with omz.
In my case, one of the locations defined in $PATH contains a folder named go. That location came before where go binary was in. Once I put that location to be after the binary location, everything just worked.
I believe maybe it has something to do with omz and how its shell functions allow you to go into a folder.
you can add '#' before command to hide output in terminal
run:
#/usr/bin/go run main.go
it outputs only 'Hello'

Use "perl6" command with Git Bash on windows

Using Windows, I installed Rakudo Star and Git and ensured that C:\rakudo\bin and C:\rakudo\share\perl6\site\bin are in my Path environment variable.
Now, typing perl6 inside Git Bash afterwards gives the command not found error, while the command does work inside powershell and cmd. Typing echo $PATH inside Git Bash confirms again that the folders above are in my path variable here as well.
How can I get the perl6 command working inside Git Bash?
Note: Using moar (moar.exe) which resides in the same folder as perl6 works as well in Git Bash. Also hitting Tab show the autocomplete suggestion for moar, it does not do that for perl6.
Bash doesn't run Windows batch files, so you'll have to work around that.
An easy solution might be to add something like this you your .bashrc:
alias perl6='cmd /c perl6.bat'
Alternatively, you can convert perl6.bat to a shell script and put it somewhere in your $PATH.
I use the following:
#!/bin/sh
PATH=/cygdrive/c/rakudo/bin:/cygdrive/c/rakudo/share/perl6/site/bin:$PATH
unset HOME
moar --execname="$0" \
--libpath='C:\rakudo\share\nqp\lib' \
--libpath='C:\rakudo\share\perl6\lib' \
--libpath='C:\rakudo\share\perl6\runtime' \
'C:\rakudo\share\perl6\runtime\perl6.moarvm' \
"$#"
This is using Cygwin; you may need to adapt it a bit for Git bash (I don't know, no experience with it).
Alternatively, if you're using Windows 10, I can recommend installing WSL, and using perl6 in a WSL bash prompt instead. This runs much smoother for me than the Windows version under Cygwin.
I tried to install perl6 from the link you provided and I can confirm the same behavior on Cygwin on Windows 10.
If I type in the Cygwin terminal window:
$ perl6
-bash: perl6: command not found
$ echo $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Users/Bruker/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/rakudo/bin:/cygdrive/c/rakudo/share/perl6/site/bin
$ cd /cygdrive/c/rakudo/bin
$ ls -l
-rwxrwx---+ 1 SYSTEM SYSTEM 930663 May 11 2017 libgcc_s_seh-1.dll
-rwxrwx---+ 1 SYSTEM SYSTEM 136146 Mar 30 20:55 libmoar.dll.a
-rwxrwx---+ 1 SYSTEM SYSTEM 56978 May 11 2017 libwinpthread-1.dll
-rwxrwx---+ 1 SYSTEM SYSTEM 7021172 Mar 30 20:55 moar.dll
-rwxrwx---+ 1 SYSTEM SYSTEM 64066 Mar 30 20:55 moar.exe
-rwxrwx---+ 1 SYSTEM SYSTEM 126 Mar 30 20:56 nqp.bat
-rwxrwx---+ 1 SYSTEM SYSTEM 126 Mar 30 20:56 nqp-m.bat
-rwxrwx---+ 1 SYSTEM SYSTEM 242 Mar 30 20:56 perl6.bat
-rwxrwx---+ 1 SYSTEM SYSTEM 248 Mar 30 20:56 perl6-debug-m.bat
-rwxrwx---+ 1 SYSTEM SYSTEM 242 Mar 30 20:56 perl6-m.bat
$ cat perl6.bat
# "C:\rakudo\bin\moar" --execname="%~dpf0" --libpath="C:\rakudo\share\nqp\lib" --libpath="C:\rakudo\share\nqp\lib" --libpath="C:\rakudo\share/perl6/lib" --libpath="C:\rakudo\share/perl6/runtime" C:\rakudo\share\perl6\runtime\perl6.moarvm %*
Notice that the paths in the bat file are not cygwin paths. So that might explain why it does not work..
For example:
$ "C:\rakudo\bin\moar"
-bash: C:\rakudo\bin\moar: command not found
$ /cygdrive/c/rakudo/bin/moar
ERROR: Missing input file.
USAGE: moar [--crash] [--libpath=...] input.moarvm [program args]
moar --dump input.moarvm
moar --help
[...]
Update:
I also tried install Git Bash, and then from the MINGW64 terminal window:
$ echo $PATH
/c/Users/Bruker/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Bruker/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Users/Bruker/AppData/Local/Microsoft/WindowsApps:/usr/bin/vendor_perl:/usr/bin/core_perl
$ PATH=/c/rakudo/bin:$PATH
$ perl6
bash: perl6: command not found
$ moar
ERROR: Missing input file.
USAGE: moar [--crash] [--libpath=...] input.moarvm [program args]
moar --dump input.moarvm
moar --help
[...]
Note that moar is an .exe file while perl6 is a .bat file.
Also it seems perl6 is not "offical" for Cygwin yet according to this issue.

Tomatousb, ls command is broken and returns just the query

I made ipkg upgrade on my old tomatousb, which it seems resulted at least in a broken ls command:
[root#tomatousb root]$ /bin/ls /
/
[root#tomatousb root]$ ls /bin
/bin
however, the results are displayed in different colours.
There is also strange behaviour:
[root#tomatousb root]$ echo $PATH
echo $PATH
sh: echo: Permission denied
[root#tomatousb root]$ /bin/echo $PATH
/bin/echo $PATH
/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin
I have no glue what's wrong to it.
The logs I see are as following:
/var/log/messages
Jan 1 04:00:11 tomatousb user.info kernel: ipt_recent v0.3.1: Stephen Frost <sfrost#snowman.net>. http://snowman.net/projects/ipt_recent/
Jan 31 23:10:21 tomatousb user.notice root: <<<< MPCSD: Config-files not found in /jffs/config/mpcs & /opt/etc/mpcs!!! Exit. >>>>
Jan 31 23:11:02 tomatousb cron.err crond[143]: time disparity of 25290430 minutes detected
Jan 31 23:37:26 tomatousb authpriv.info dropbear[505]: Child connection from *.*.*.*:*
So, basically, when I do SSH, I get to dropbear.
It seems that during the last ipkg upgrade I got new bash, tcpdump, and two more items, but I can't recall which exactly.. And I can't find the ipkg logfile...
Finally I bumped into my own old discussion when I had the same issue with the same box, and here's what was the reason:
[root#tomatousb mnt]$ cat /opt/etc/profile
#
# Bash initialization script
#
PS1="[\u#\h \W]$ "
PATH=/opt/sbin:/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin
LD_LIBRARY_PATH=/opt/lib:${LD_LIBRARY_PATH}
export PS1 PATH LD_LIBRARY_PATH
[root#tomatousb mnt]$ rm /opt/etc/profile
Then I did reboot, and everything restored back to normal operation!
Do not know what exactly was in that profile file that ruined everything and caused 'memory exhausted' error when running vi.

Why are my Snort logs empty?

I am running macOS Sierra 10.12.3
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.3
BuildVersion: 16D32
I have installed snort using homebrew
$ brew install snort
$ brew ls --versions snort
snort 2.9.9.0
I am running snort and with a user config file, -s syslog switch, and a tcpdump-file
$ sudo snort -c /etc/snort/snort.conf -s -r tcpdump.pcap
my /etc/snort/snort.conf file has the following output settings:
output alert_syslog: LOG_AUTH LOG_ALERT
When I execute,a blank file gets created at /var/log/snort/snort.log.1489953549
I know that my rules are working, because if I execute snort with an alert-mode of fast
$ sudo snort -c /etc/snort/snort.conf -A fast -r tcpdump.pcap
a new blank /var/log/snort/snort.log.1489954258 is created, but a /var/log/snort/alert log file is also created, which contains the correct alert outputs.
I have seen others run into this issue because of permissions, but I don't believe that is my problem given that I am running snort as sudo and it is able to write to the alert log just fine.
I also do not have $NO_PACKET_LOG as far as I can tell. reference
It looks like brew installed some default snort config files under /usr/local/etc/snort, but I don't think that these are affecting me because I am using the -c switch to supply a user config file.
DISCLAIMER: This is my first time using snort, so it could be something very obvious that I am missing. Any and all help is much appreciated.
TL;DR
Use tcpdump, snort, tshark, or Wireshark to read snort log files (how to view snort log files)
$ sudo tcpdump -r snort.log.1489953549
My empty log file was never actually empty (note file sizes from ls)
$ ls -ltr /var/log/snort/
-rw------- 1 root admin 56018718 Mar 19 15:03 snort.log.1489954258
-rw------- 1 root admin 56018718 Mar 19 15:11 snort.log.1489953549
-rw-r--r-- 1 root admin 70202224 Mar 19 15:11 alert
Snort log files must be read using the correct application
What type of file is it?
$ sudo file snort.log.1489953549
snort.log.1489953549: tcpdump capture file (little-endian) - version 2.4 (Ethernet, capture length 1514)
Read the file with tcpdump
$ sudo tcpdump -r snort.log.1489954258
06:54:16.654692 IP 192.168.5.81.amt-blc-port > 100.100.100.212.6667: Flags [P.], seq 1304973037:1304973067, ack 1425084530, win 8011, options [nop,nop,TS val 14215752 ecr 2196036272], length 30
...

JSON2CSV install/setup issue (via Go)

I'm attempting to install https://github.com/jehiah/json2csv. The problem is apparently tied to my noob status w.r.t. Bash.
System: Ubuntu 14.04 LTS
Load instruction:
$ go get github.com/jehiah/json2csv
Go is installed:
$ which go ==> /usr/bin/go
~/.bashrc setup:
export GOROOT=/usr/bin/go
export GOPATH=$HOME/projects/go
The package seems to download correctly:
$ cd projects/go
$ tree
$ > bin > json2csv
> src > github.com
...
$ ls bin -l
$ > -rwxrwxr-x 1 <user> <user> 55400 Feb 5 13:57 json2csv
But $json2csv isn't recognized, even from the same directory. I'm sure this is a noob problem, but I haven't cracked it yet. Suggestions?
Add $GOPATH/bin to your PATH variable in your shell,
for bash:
export PATH=$GOPATH/bin:$PATH

Resources