I have implemented a api from which I wanted to run docker commands. Most commands worked fine, but when I tried to run the following command
{
"command":"docker run -d -p 1506:1506 –p 2003:2003 --name=dradis dradis-licensed:v1"
}
on the server side the 2nd '-p' parameter was actually being converted to '?p'
Any clues why this would happen and any escape charaters I should be using?
Cheers
Kris
Related
I'm trying to run a mysql query on a remote host using a bash script.
${MYSQL} -u ${USER} -p${PASS} -P${PORT} -h ${HOST} -e "select * from information_schema;"
My PASS looks something like "dfsf#DFD". It conatins '#' character.
For some reasons the PASS is not retrieving correctly in the script. Its getting chopped off after '#'.
And for some reason including source /etc/environment in the script, seems to fix the problem.
I want to understand why is this happening. How to make it work without the source statement.
As far as I know - the safest way to specify remote connection details for MySQL is using configuration file: https://dev.mysql.com/doc/refman/8.0/en/option-files.html
So briefly you just put something like this in ~/.my.cnf file:
[client]
host='...'
port='...'
user='...'
password='...'
And then you simply run
mysql -e "select * from information_schema;"
Not sure it suits your situation, but it should solve your issue, if you quote the values.
Quoting at command line is also a solution, but your credentials will be visible to everyone able to see your processes at the system where you run that.
I'm trying to access mysql using Git Bash and/or ConEmu but it doesn't work.
I'm using the command: mysql -u root -p
ConEmu : ask me to enter the password. I write it but nothing happen. (the password is also really randomly hidden with *, some char yes other not, it depends).
Git Bash : after I text mysql -u root -p doesn't make anything.
everything works with normal windows CMD.
What do I do wrong guys ?
This is likely a terminal issue arising from clashes between git bash (cygwin) and the windows command prompt. A similar question prompts a number of good answers, including:
winpty mysql
On the 8.0.29 build I have locally, the mysql command line is invoked with the slightly differently named mysqlsh.exe, and I can get it to run with
winpty mysqlsh
You can alias this command in the usual bash way.
alias mysql='winpty mysqlsh'
I am a Linux user and do not have a whole lot experience with Windows.
My assumption is that if you run Windows, then your version of mysql that you run within CMD is absolutely different from mysql that you run within Git Bash. This is why it will not run as you would expect.
If you have file command within Git Bash environment, try running file $(which mysql). In case it is a Linux version and can be run from Git Bash it will output something like this.
/usr/bin/mysql: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, fo
r GNU/Linux 3.2.0, BuildID[sha1]=25171134a33827663abd4250e4e33ea524dd3d01, stripped
I'm trying to execute below mysql command via ssh, of course this command works fine on server A, and I'm trying to execute it from server B via ssh.
ssh accountId#serverA "(cd dir1/dir2/; mysql --login-path=develop)"
but it fails with
mysql: unknown variable 'login-path=develop
does anyone know the reason?
Manual page for bash explains the meaning of the braces as:
(list)
list is executed in a subshell environment (see COMMAND EXECUTION ENVIRONMENT below). Variable assignments and builtin commands that affect the shell's environment do not remain in effect after the command completes. The return status is the exit status of list.
This means that you are executing the commands on the machine A. If you really want to execute the commands in the subshell on remote machine, you need to escape the braces:
ssh accountId#serverA "\(cd dir1/dir2/; mysql --login-path=develop\)"
if you don't know what is it, just remove them. In this case, they do not matter:
ssh accountId#serverA "cd dir1/dir2/; mysql --login-path=develop"
I found the root cause and fixed!!! I'm posting it for someone who might suffer from similar problem.
My problem was several mysql binaries on serverA. The 'mysql' binary, one that I executed on serverA and from serverB via ssh were different. So I modified the command to use absolute path for mysql and it works fine now.
ssh accountId#serverA "(cd dir1/dir2/; /user/bin/mysql --login-path=develop)"
For anyone else who runs into the same problem as I did, check your bash alias file. I forgot I added this to mine recently:
alias mysql='mysql --login-path=local -A'
So when I ran mysql --login-path=local -A I was actually running:
mysql --login-path=local -A --login-path=local -A
Which gave me this error:
mysql: [ERROR] unknown variable 'login-path=local'.
I solved this problem by changing the order of the parameters
First Version:
mysql -NBA --login-path=my_credentials
failed with
mysql: [ERROR] unknown variable 'login-path=my_credentials'
This could be solved with
mysql --login-path=my_credentials -NBA
rails dbconsole detects the native DB client and loads it up with all the proper credentials and parameters passed. Is there a way to pass additional parameters to the DB client?
For instance, if you're using mysql, it will load up mysql client. I'd like to be able to pass arguments such as mysql -e 'SELECT NOW();' or whatever custom query I would like.
No, what you're asking is not possible. You can pass some options though, check
$ rails dbconsole -h
Usage: rails dbconsole [environment] [options]
-p, --include-password Automatically provide the password from database.yml
--mode [MODE] Automatically put the sqlite3 database in the specified mode (html, list, line, column).
--header
-h, --help Show this help message.
-e, --environment=name Specifies the environment to run this console under (test/development/production).
Default: development
What you're asking is not perfectly possible!
echo -e "SELECT NOW();\n" | rails dbconsole
I am trying to to load pgrouting in extension in postgis database named as "routing" the problem I am facing is I type in osgeo shell in "C:\Program Files (x86)\Boundless\OpenGeo\bin" "psql -U postgres routing" and it gives the error of "psql : illegal option --u"
Are you sure, that your wrote "-U" and not "-u" in lower case? Because this is what the error tells you. If you connect to the database routing using: psql -U postgres routing then it should be all right.