In bash, I can redirect stderr using 2>&1 with the find command and pipe it to grep to remove any Permission denied messages. How do I do this in csh? I am getting the error message Ambiguous output redirect. I have already tried the syntax at this question, and it gives me the error described.
Theoretically you can use "! -executable -prune -o ..." to enter only accessible directories.
Per the link that #swdev posted in a comment above, the only way to do this by sending it to a file and then using grep on that file when you are in csh.
Related
I'm using WSL with docker (with a complex pandoc configuration with latex, python and pandoc-filters) and trying a long command with --filter=filters/the_filter.sh that results in an error:
Error running filter filters/the_filter.sh: ./filters/the_filter.sh: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
My filter is a .sh wrapper, mostly to make sure I'm using Python3 (which may not be needed, but I got the hint from here):
#!/bin/sh
python3 filters/the_filter.py $#
Googling the error shows lots of GitHub issues, but no definitive explanation on Stack overflow.
It turns out that my .sh file had Windows line endings: \r\n.
I assume that the system was trying to find /bin/sh\r but the error message is not explaining it.
Correcting the line-endings using dos2unix filters/the_filter.sh, I was able to get rid of the error.
Here are more details of a related problem.
I'm trying to grep my repo searching for # sign to find some e-mail addresses because of this git issue.
I type grep -rnw '/my/path' -e '#' into the terminal and I get:
Why does it happen?
P.S. I think there is no sensitive information in the picture, but someone please tell me if you think there is.
If you have issues only on files within a .git folder, you might consider excluding it from your recursive grep, as in this answer.
grep --exclude-dir=".git" -nrw ...
On CentOS, the regular grep might not include that option though.
I'm using a wonderful libssh wrapper for Objective-C called NMSSH. I am able to make a connection, send commands, etc, but I'm having some trouble. Whenever I send an elevated command like "sudo..something", I get the following error in my response object:
Error: Error Domain=NMSSH Code=0 "sudo: no tty present and no askpass program specified
" UserInfo=0x145a65e0 {command=sudo apachectl start, NSLocalizedDescription=sudo: no tty present and no askpass program specified
, NSLocalizedFailureReason=54}
How can I tell the program what the password is?
Use sudo -S:
[session.channel execute:#"echo password | sudo -S apachectl start" error:&error];
From the man page:
The -S (stdin) option causes sudo to read the password from the
standard input instead of the terminal device. The password must be
followed by a newline character.
jonahb's solution is a nice and easy way to do it but it is very unsecure!
In case anyone wants to do it in a securer way he should edit the "Sudoers File" on the target system if possible like showen here or here.
Just start editing with
sudo visudo
and past the edited version from:
USERNAME ALL=(ALL) NOPASSWD: /path/to/script
in the very end of the file.
I used the following syntax in order to find IP address under /etc
(answered by Dennis Williamson in superuser site)
but I get the message "grep: line too long".
Someone have idea how to ignore this message and why I get this?
grep -Er '\<([0-9]{1,3}\.){3}[0-9]{1,3}\>' /etc/
grep: line too long
The find/xargs solution didn't work for me, but resulted in the same error.
I solved this problem by using the -I grep option (ignore binary files). In my case there must have been a binary file in the list of files to search that had no linebreaks, so grep tries to read in a gigantic line that is too big. That's my guess at what this error means.
I got the idea from: http://web.archiveorange.com/archive/v/am8x7wI0r0243prrmYd4
This might not work for you of course if there's a text file with a line that is too long.
Use find to build a list of files to grep,
find /etc -type f -print0 | xargs -r0 grep -E '\<([0-9]{1,3}\.){3}[0-9]{1,3}\>'
In general find is a more flexible way of traversing the filesystem and building lists of files for other programs.
Perhaps your grep has a bug and scans by accident a binary file with too long lines (i.e. too much characters for grep to handle between two newlines). See this red hat page for more details (bug page).
i am developing on 5 different rails projects, plus also refactoring some (moving from older rails versions to 2.3) - what is the best way to extract the error information from the logfiles, so i can see all the depreciation warnings, runtime errors and so on, so i can work on improving the codebase?
are there any services or libraries out there you can recommend, that actually help with rails logfile parsing?
Read about grep linux command.
http://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/
I don't know what error log format is in Rails, but I guest every row with warning or error contain "warning" or "error" word.
Then it would be like this:
grep -E "error|warning" logfile.txt
for bot error and warnings
grep "error" logfile.txt
for errors
grep "warning" logfile.txt
for warnings
and if you want to see new errors and warnings in real time, try this
tail -f logfile.txt | grep -E "error|warning"
tail -f logfile.txt | grep "error"
tail -f logfile.txt | grep "warning"
Hope I could help you ;) and I hope that I'm not wrong about logs format in Rails
I've found the request-log-analyzer project to be very useful.
You can certain grep the log to find errors and dump them out, but this does an excellent job of gathering all the information about the different actions and how long they take.
Here's some sample output.
This is the first thing I run when I get a call saying "my site is slow and I need help fixing it."
Hoptoad and/or Exceptional are great for ongoing errors, but they don't track log running requests. Something like New Relic is good for that.
I use hoptoadapp, http://www.hoptoadapp.com/pages/home there is a free flavor, it logs your error messages to their database, and they provide an easy to use interface. All you have to do is install this plugin: http://github.com/thoughtbot/hoptoad_notifier.
It won't help for past errors, but it is great for isolating problems with a currently running app.