scrot : giblib error saving to file failed - centos7

I have installed Scrot on Centos 7,
giblib error saving to file ***.png failed
occurs for
scrot -s
Help for a solution. Thanks a lot.

Are you telling scrot to save to an explicit file?
Several things can go wrong:
you target a file that has an unsupported extensions. scrot -s asdf doesn't work. scrot -s asdf.png does.
I've seen scrot examples with quotes in the output. Special characters can mean trouble within quotes, for example ~. scrot ~/asdf.png works, scrot "~/asdf.png" doesn't work. Single quotes do not work either. That's the same as with mv, special character expansion. This gives a giblib error, which is a little confusing.
If this is your problem, do not to use quotes, use absolute pathes, or let scrot create its default file and move it afterwards as described here:
scrot -e 'mv $f ~/Pictures/screenshots'

Related

Bash on macOS: How replace a path in a file with another string?

For integration tests, I have output that contains full file paths. I want to have my test script replace the user-specific start of the file path (e.g. /Users/uli/) with a generic word (USER_DIR) so that I can compare the files.
The problem, of course, are the slashes in the path. I tried the solutions given here and here, but they don't work for me:
#!/bin/bash
old_path="/Users/uli/"
new_path="USERDIR"
sed -i "s#$old_path#$new_path#g" /Users/uli/Desktop/replacetarget.txt
I get the error
sed: 1: "/Users/uli/Desktop/repl ...": invalid command code u
This is the version of sed that comes with macOS 10.14.6 (it has no --version option and is installed in /usr/bin/, so no idea what exact version).
Update:
I also tried
#!/bin/bash
old_path="/Users/uli/"
old_path=${old_path//\//\\\/}
new_path="USERDIR"
regex="s/$old_path/$new_path/g"
echo $old_path
echo $regex
sed -i $regex /Users/uli/Desktop/replacetarget.txt
But I get the same error. What am I doing wrong?
BSD sed requires an argument following -i (the empty string '' indicates no backup, similar to argumentless -i in GNU sed). As a result, your script is being treated as the backup-file extention, and your input file as the script.
old_path="/Users/uli/"
new_path="USERDIR"
sed -i '' "s#$old_path#$new_path#g" /Users/uli/Desktop/replacetarget.txt
However, sed is a stream editor, based on the file editor ed, so using -i is an indication you are using the wrong tool to begin with. Just use ed.
old_path="/Users/uli/"
new_path="USERDIR"
printf 's#%s#%s#g\nwq\n' "$old_path" "$new_path" | ed /Users/uli/Desktop/replacetarget.txt
Obligatory warning: neither editor is parameterized as such; you are simpling generating the script dynamically, which means it's your responsibility to ensure that the resulting script is valid. (For example, if either parameter contains a ;, it had better be escaped to prevent (s)ed from seeing it as a command separator.)

Multi-line regular expression issue in Perl on Windows 10.

I'm trying to convert this pattern in files
Insert 18333fig0101.png
Figure 1-1. Local version control diagram.
to
![Figure 1-1. Local version control diagram.](../figures/18333fig0101-tn.png)
This is the perl command:
perl -i -0pe 's/^Insert\s*(.*)\.png\s*\n([^\n]*)$/!\[\2](..\/figures\/\1-tn.png)/mg' */*.markdown
This works fine on Mac OS X, but it doesn't work on Windows 10.
I installed perl using pacman -S perl from MSYS2.
This is also not a \r\n issue as I checked there is no \r in the document.
Is this a known issue on Windows? Or, is there something different option needed for Windows?
When I run the same command (after changing single quotes to double quotes), I get the following error message:
Can't do inplace edit without backup.
This is documented in perldiag:
You're on a system such as MS-DOS that gets confused if you try
reading from a deleted (but still opened) file. You have to say -i.bak, or some such.
When I change the command to perl -i.bak ..., it works.

Linux console perl replace not working on large file

On ubuntu I'm running a console perl replace on a csv file of ~500MB. This is the call:
perl -i -pe 's/AS100\n/AS100/g' test.csv
Before run it on the complete file, I extracted a subset of it of ~30MB and run this script successfully.
When running on the full file, no substitution is done, and no error or message is showed.
I've tried also with sed, but the behavior is the same.
How can I solve this issue?
Thank you
If you have room, try to do this instead to look at the substitution as it is done to another file:
perl -pe 's/AS100\n/AS100/g' test.csv | tee > test2.csv
My question is though, is it only the rows ending with AS100 that needs the newline removal?
After trying everything, I found out that in the original file the pattern was:
As100\r
and that the \n was a conversion done by Sublime Text when saving the test file.
So the correct code to do the trick was:
perl -i -pe 's/AS100\r/AS100/g' test.csv

rpm build error

I tried to build a rpm package which is giving me the following error
/usr/lib/rpm/find-debuginfo.sh /usr/src/redhat/BUILD/RPMS
find: invalid predicate `'
error: Bad exit status from /var/tmp/rpm-tmp.86590 (%install)
what could be the reason .can any one help me in this...Thanks
Try defining the BuildRoot variable in your spec file. The find-debuginfo script looks in to that directory several times, and will die without it.
This will usually look something like: BuildRoot: %{_tmpdir}/%{name}-%{version}-%{release}
As to your second question, I can't say without seeing spec file and sources directly, and I am by no means an RPM expert. I will recommend you to Chapter 13 of Maximum RPM(there are copies available free online), and the notes from Tom Callaway's presentation on How to make good RPM packages - I've found the spec examples here to be very helpful in the past.
In your spec you can do this at the top:
%define debug_package %{nil}
This should bypass this problem
I just hit this same problem when attempting to build on a RedHat 5.3 server. Here is what I found. The error appears to be caused by an empty RPM_BUILD_ROOT variable. Below is one offending line:
find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \
\( -perm -0100 -or -perm -0010 -or -perm -0001 \) \
-print |
If RPM_BUILD_ROOT hasn't been defined, then the first argument to find is an empty string "", which causes this error. Interestingly enough, if you remove the quotes from around $RPM_BUILD_ROOT, then command works fine since the first argument would become the "!". Since it's not required to define a "BuildRoot:" in the spec file, this certainly looks like a bug to me.

Is there any way to get readable gcc error and warning output at the command line?

For some long errors, the gcc output is dense and has lots of line-wrapping etc. Especially when errors are subtle, it can take me 10-30 seconds of squinting to parse it with my eyes.
I've taken to pasting this in an open code-editor window to get some basic syntax highlighting and enable reformatting with regex's.
Has anyone invented a more automated method?
I use this script, called colorize:
#!/bin/bash
while read x ; do echo $x ; done \
| sed -e "s/.*error:.*/\x1b[1;36m&\x1b[0m/" \
-e "s/.*warning:.*/\x1b[1;36m&\x1b[0m/" \
-e "s/^\(.*\)\(required from\)/\x1b[1;36m\1\x1b[0mnote: \2/" \
-e "s/^\(.*\)\(In instantiation of\)/\x1b[1;36m\1\x1b[0mnote: \2/" \
-e "s/^\(.*\)\(In member\)/\x1b[1;36m\1\x1b[0mnote: \2/" \
| sed -e "s/error:/\x1b[1;31m&\x1b[1;36m/" \
-e "s/warning:/\x1b[1;35m&\x1b[1;36m/" \
-e "s/note:/\x1b[1;30m&\x1b[0m/"
Then I just call it like this(using make or whatever build system):
make |& colorize
And I get color output similar to clang.
I've found colorgcc to be invaluable. By introducing coloring, it becomes much easier to mentally parse the text of gcc error messages, especially when templates are involved.
If your errors are template related, take a look at STLfilt:
http://www.bdsoft.com/tools/stlfilt.html
gccfilter does coloring & simplification of messages.
http://www.mixtion.org/gccfilter/
If you use GCC 4.9, you can add -fdiagnostics-color=auto as an additonal compilation flag. At some later version, the color has been enabled by default.
check diagcc out, you can get something like this:
If your gcc ≥ 4.9, you can use argument -fdiagnostics-color=always.
To answer your question 4 years later, clang should be mentioned here.
Here's my current hack, which mostly inserts newlines and indentation in strategic locations along with a little extra annotation, but does nothing to address STL verbosity.
Note that as currently implemented, this script does not return an error if the compiler returned one, so doing something like this will not work properly: (make && ./runApplication). This could surely be remedied by someone with better bash-fu.
#!/bin/bash
# SUBSTITUTION RULES:
# Note: All substitution rules must end in a semi-colon, inside of the closing quote
subColonSpace='s/: /:\n /g;'
subSrc='s/^src/\nsrc/;'
subError='s/error:/error:\n\n======================================\nERROR:/;'
subWarning='s/ *error: *\n/ERROR: /;'
subWarning='s/ *warning: *\n/WARNING: /;'
subNote='s/note:/\n NOTE:/g;'
subOpenTic='s/‘/\n ‘/g;'
subOpenParen='s/(/(\n /g; s/(\n *)/()/g;'
subCommaSpace='s/, /,\n /g;'
# Note: The order of these may matter
sedExpr="$subColonSpace $subSrc $subError $subWarning $subNote $subOpenTic
$subOpenParen $subCommaSpace"
makelogFile=makelog.tmp
make "$#" 2>&1 | sed "$sedExpr" | tee $makelogFile
if you like Ruby there is GilCC! GilCC is very easy to install (just copy it to the bin folder) and easy to use (just type GilCC instead of "gcc" or "make") and it works with GCC version. Unlike Perl based scripts GilCC has statistics such as # of warnings and error and compile time. You don't have to mess with .bash files and it is cross platform as long as you can run Ruby on your machine. Since it has the power of Ruby; you can make GilCC do different things such as trigger test automation, unit test or program external hardware after a successful build.
Here is the link to the download page: http://www.onlysolutionssoftware.com/gilcc/