psql: warning: extra command-line argument ignored - psql

I'm trying to execute a script to create a role in postgres
$PSQL_CLIENT "host=$servername user=$DB_POSTGRES_USERNAME dbname=postgres password='$DB_PASSWORD'"
the issue is with the password it has 6 words like(alpha beta charlie) and whitespaces and I'm not allowed to change it
I also tried:
$PSQL_CLIENT "host=$servername user=$DB_USERNAME dbname=postgres password=/"$DB_PASSWORD"/"
everytime I'm trying to connect I'm seeing this error
psql: warning: extra command-line argument "password content" ignored
psql: warning: extra command-line argument "password content" ignored
psql: warning: extra command-line argument "password content" ignored
psql: warning: extra command-line argument "password content," ignored
I think something has to be changed at password=/"$DB_PASSWORD"/" not sure what exactly needs to be done to read the password properly. Any help would be appreciated

As the documentation says:
To write an empty value, or a value containing spaces, surround it with single quotes, for example keyword = 'a value'.
So your command should work well for passwords containing spaces. You will still have a problem if your password contains ' or \, because
Single quotes and backslashes within a value must be escaped with a backslash, i.e., \' and \\.
So you need to use
IFS='' escapedpwd=$(echo "$DB_PASSWORD" | sed -e "s/\([\']\)/\\\\\1/g")
$PSQL_CLIENT "host=$servername user=$DB_POSTGRES_USERNAME dbname=postgres password='$escapedpwd'"

Related

neo4j-admin import "Multi-line fields are illegal"

I'm getting the following error in Neo4j community 4.1.2 using the neo4-admin import tool.
Caused by:ERROR in input
data source: BufferedCharSeeker[source:/home/ubuntu/workspace/neo4j-community-4.1.2/bin/../import/nodes.csv, position:24455, line:359]
in field: code:string:6
for header: [id:ID, labels:LABEL, type:string, flags:string, lineno:string, code:string, childnum:string, funcid:string, classname:string, namespace:string, endlineno:string, name:string, doccomment:string]
raw field value: 402
original error: At /home/ubuntu/workspace/neo4j-community-4.1.2/bin/../import/nodes.csv # position 24455 - Multi-line fields are illegal in this context and so this might suggest that there's a field with a start quote, but a missing end quote. See /home/ubuntu/workspace/neo4j-community-4.1.2/bin/../import/nodes.csv # position 24455.
I checked each single byte with hexedit:
the line #359
the char #24455
the line #358
the line #360
357,AST,string,,34,"/load.php",1,310,,"",,,
358,AST,AST_CALL,,37,,9,310,,"",,,
359,AST,AST_NAME,NAME_NOT_FQ,37,,0,310,,"",,,
360,AST,string,,37,"wp_check_php_mysql_versions",0,310,,"",,,
361,AST,AST_ARG_LIST,,37,,1,310,,"",,,
362,AST,AST_INCLUDE_OR_EVAL,EXEC_REQUIRE,40,,10,310,,"",,,
This is the absurd situation:
no multi-line fields are present
no special char are present
no extra 0A byte
no extra "start quote" without its relative "end quote"
I found some issues on Github but are referred to old versions of Neo4j...what can be the reason?
Finally I found the line causing the exception.
The exception cause was correct but the number of the line was totally wrong.
I pointed out it by adding the following flag --multiline-fields=true to the neo4j-admin import command.

:erlang.list_to_atom("roster") error when accessing mnesia table

I am trying get mnesia table info from elixir shell.
I have tried to convert the string to atom.
String.to_atom("roster")
I have tried to pass string as list ["roster"]
command -
:ejabberd_admin.mnesia_table_info("roster")
error
ArgumentError
:erlang.list_to_atom("roster")
Erlang expects a charlist there, not a binary. Use single quotes:
:ejabberd_admin.mnesia_table_info('roster')
Also: Kernel.to_charlist/1, ~c/2.
Documentation on charlists on official site.
Example:
iex(1)> :erlang.list_to_atom("roster")
** (ArgumentError) argument error
:erlang.list_to_atom("roster")
iex(1)> :erlang.list_to_atom('roster')
:roster

Check if environment variable is set in configure script?

I'm trying to test if ANDROID_NDK_ROOT is set in an Autoconf script. The relevant stanza is shown below. According to How can I check an environment variable? on the Autoconf mailing list, I can use:
if test "${var+set}" = set; then
echo "variable \$var is set to: $var"
fi
The variable is not set, but my AC_MSG_ERROR is not being executed.
$ printenv | grep ANDROID_NDK_ROOT
$
Instead, the test is producing the following error:
./configure: line 20616: syntax error near unexpected token `('
./configure: line 20616: ` $as_echo_n "(cached) " >&6'
(There's another reply in the thread but it seems to be just a comment and does not answer the question).
How do I test if an environmental variable is set in Autoconf?
Here is the stanza I am trying to execute in configure.ac:
# if test "$IS_ANDROID_OS" != "0"; then
if true; then
if test "${ANDROID_NDK_ROOT+set}" != set; then
AC_MSG_ERROR([ANDROID_NDK_ROOT is not set. Please set ANDROID_NDK_ROOT])
fi
THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h"
AC_CHECK_FILE([$THIS_FILE],
[cp "$THIS_FILE" "$ac_srcdir"],
AC_MSG_RESULT([cpu-features.h does not exist in ANDROID_NDK_ROOT, skipping])
)
THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c"
AC_CHECK_FILE([$THIS_FILE],
[cp "$THIS_FILE" "$ac_srcdir"],
AC_MSG_RESULT([cpu-features.c does not exist in ANDROID_NDK_ROOT, skipping])
)
fi
Here is the chunk of configure from cat -n:
20610
20611 THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c"
20612 as_ac_File=`$as_echo "ac_cv_file_$THIS_FILE" | $as_tr_sh`
20613 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $THIS_FILE" >&5
20614 $as_echo_n "checking for $THIS_FILE... " >&6; }
20615 if eval \${$as_ac_File+:} false; then :
20616 $as_echo_n "(cached) " >&6
20617 else
20618 test "$cross_compiling" = yes &&
20619 as_fn_error $? "cannot check for file existence when cross compiling""$LINENO" 5
20620 if test -r "$THIS_FILE"; then
20621 eval "$as_ac_File=yes"
20622 else
20623 eval "$as_ac_File=no"
20624 fi
I came across this old question and figured I'd share a solution I ended up using when I needed to check multiple variables were set (in this sanitized example, VAR1 thru VAR4):
m4_foreach_w([my_var],[VAR1 VAR2 VAR3 VAR4],[
AS_VAR_IF(myvar, [], AC_MSG_ERROR([Missing required variable: myvar!]))
AC_SUBST(myvar)dnl Export variable to Makefile as well
AC_ARG_VAR(myvar, [])dnl if this variable changes, re-run configuration
])
There's nothing wrong with your shell syntax for testing whether a variable is set, and it works fine with Autoconf.
The problem appears to arise from failing to quote the third arguments to the AC_CHECK_FILE() macros. You should always quote (with square brackets) each argument to each macro, especially when that argument is or contains a macro call itself. I can reproduce a syntax error in configure by wrapping the example code you provided between an AC_INIT and an AC_OUTPUT, but it goes away with proper quoting. Specifically, here:
THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h"
AC_CHECK_FILE([$THIS_FILE],
[cp "$THIS_FILE" "$ac_srcdir"],
[AC_MSG_RESULT([cpu-features.h does not exist in ANDROID_NDK_ROOT, skipping])]
)
THIS_FILE="$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c"
AC_CHECK_FILE([$THIS_FILE],
[cp "$THIS_FILE" "$ac_srcdir"],
[AC_MSG_RESULT([cpu-features.c does not exist in ANDROID_NDK_ROOT, skipping])]
)
Failing to quote the argument results in it being expanded too many times, and the resulting output indeed is not syntactically valid shell code.

Doxygen: Can a \post start with \ref or any other Special Command?

I'm getting an error from Clang when using CLANG_WARN_DOCUMENTATION_COMMENTS on a doxygen block that contains following line
\post \ref something == somethingelse
The warning says "Empty paragraph passed to '\post' command"
Is this a valid use of \post?
If it is, does anyone know if there's a way to suppress this warning without disabling all documentation warnings?
Cheers.

The regular expression construct \p{ name } is not working in ruby

I am trying the regular expression construct
like \p{IsGreek} and \p{IsBasicLatin}
but I am getting this error
config/initializers/app_constants.rb:13: invalid character property
name {IsBasicLatin}
It seems like Ruby does not support Unicode Blocks, but it does support Properties and Scripts. See Character Properties on ruby-doc.org.
That means you can use the Unicode scripts:
\p{Latin}
\p{Greek}
For an introduction to Unicode Properties, Scripts and Blocks you can have a look at regular-expressions.info
Try the following instead:
\p{Greek}
\p{Latin}
Documentation here:
http://ruby-doc.org/core-2.0/Regexp.html
Ruby 2.0 adds support for Unicode blocks:
$ ruby-1.9.3-p484/bin/ruby -e "p /\p{InBasicLatin}/"
-e:1: invalid character property name {InBasicLatin}: /\p{InBasicLatin}/
$ ruby-2.0.0-p353/bin/ruby -e "p /\p{InBasicLatin}/"
/\p{InBasicLatin}/
Note that you have to use In, not Is.

Resources