Find Jobs
Hire Freelancers

write command: Running mysql from ssh & query statement has a Text Header in the SELECT statement that needs quotes.

$10-30 USD

Concluído
Publicado há mais de 10 anos

$10-30 USD

Pago na entrega
I have an mySQL statement that works locally: mysql -u root -ppassword -e 'SELECT "Column 1 text" as "Column 1 Heading", table1.* FROM table1;' dataBase1 If I try and run it with SSH, it errors out. I don't know how to get the quote in the SQL statement through SSH. ssh server1 "mysql -u userName -ppassword -e 'SELECT 'Column 1 text' as 'Column 1 Heading', table1.* FROM table1;' dataBase1" Just need the command written correctly so it runs on the command line. No changes to the system are allowed. OS: Linux version [login to view URL] () (gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC) ) #1 SMP Fri Oct 22 15:27:53 UTC 2010 mySQL: "protocol_version" "10" "version" "5.1.51-log" "version_comment" "Source distribution" "version_compile_machine" "i386" "version_compile_os" "redhat-linux-gnu" Thanks, ~Donavon
ID do Projeto: 5141352

Sobre o projeto

18 propostas
Projeto remoto
Ativo há 10 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
Concedido a:
Avatar do Usuário
This project is actually so silly that I'll give you the solution right here (and explain). :P What ssh does is connect to server1 and run the command with a shell ... After being parsed by the local shell. That means all special symbols are going to be parsed twice. In a way, this is pretty much the same as running CMD vs. sh -c "CMD" What's left cannot work because you're using single quotes the wrong way. So 'SELECT 'Column 1 text' as 'Column 1 Heading', table1.* FROM table1;' will be parsed as, in python terms, ['SELECT Column', '1', 'text as Column', '1', 'Heading'], whereas it is expected to be a single monolithic string. What to do about this? The most simple fix is to explictly escape all shell-specific characters, eg. quotes, single quotes, semicolons etc, before passing them to the local shell. The trick is knowing which ones yes and which ones not. Your call would be fixed by using this instead: ssh server1 "mysql -u root -ppassword -e 'SELECT \"Column 1 text\" as \"Column 1 Heading\", table1.* FROM table1;' dataBase1" You can also try to use this function for more generic conversion: chars='[\"\ \t\&'\'']' function convertInputForSsh() { for i in "${@}"; do echo -n $(echo ${i} | sed -e "s,\(${chars}\),\\\\\1,g")\ ; done; } Example: CMD=(for i in 1 '2 3' '4 5' 6\; do echo \${i}\; done) > ssh server1 "${CMD[@]}" 1 2 3 4 5 6 vs. > ssh server1 $(convertInputForSsh "${CMD[@]}") 1 2 3 4 5 6
$15 USD em 1 dia
4,8 (3 avaliações)
1,9
1,9
18 freelancers estão ofertando em média $17 USD for esse trabalho
Avatar do Usuário
Hi there, I have over 7 years experience working on HTML, Wordpress, Magento, Database administration, OpenCart, Website Design, Logo / Banner Design Joomla, CSS and Linux Administration. I have read the project description very well, and i would like to complete this project. lets complete this project
$23 USD em 1 dia
4,8 (941 avaliações)
8,5
8,5
Avatar do Usuário
A proposal has not yet been provided
$10 USD em 1 dia
4,9 (199 avaliações)
7,0
7,0
Avatar do Usuário
Should really be an easy going quiz time :) I'd be glad to help, and I'm definitely sure I have the solution ;) Thank you.
$15 USD em 0 dia
5,0 (20 avaliações)
5,1
5,1
Avatar do Usuário
I can help you to do this job right now. lets start. thanks ------------------------------------------------------------------------------------
$25 USD em 3 dias
4,9 (38 avaliações)
5,0
5,0
Avatar do Usuário
Hi I have 3+ years experience in MySQL and Linux. I will help you sort this out. Please let me know if you are interested. Thanks
$25 USD em 0 dia
5,0 (27 avaliações)
4,4
4,4
Avatar do Usuário
I usually do something like this and escape the command watching for asterisks and the like that the shell will try to interpret. echo "escaped_command" | ssh user@host $(< /dev/fd/0)
$15 USD em 1 dia
4,6 (10 avaliações)
4,2
4,2
Avatar do Usuário
Hi, it should be: ssh server1 "mysql -u userName -ppassword -e 'SELECT \"Column 1 text\" as \"Column 1 Heading\", table1.* FROM table1;' dataBase1" Regretfully I do not have a linus at my disposal, so I hope you would be kind enough to award me the project if it works. Regards, Diego Sorry, didn't update the price.
$10 USD em 1 dia
5,0 (8 avaliações)
3,0
3,0
Avatar do Usuário
I Could help you. . . .
$20 USD em 1 dia
5,0 (1 avaliação)
2,0
2,0
Avatar do Usuário
Hi! Try this: ssh server1 "mysql -u userName -ppassword -e 'SELECT \"Column 1 text\" as \"Column 1 Heading\", table1.* FROM table1; dataBase1'" I tried to simulate a setup more or less the same on my laptop, and it worked for me when I used quotes ( " ) and escaped them with a backslash ( \ ). Hope that helps! Mark
$10 USD em 1 dia
0,0 (0 avaliações)
0,0
0,0
Avatar do Usuário
A proposal has not yet been provided
$15 USD em 1 dia
5,0 (1 avaliação)
0,2
0,2
Avatar do Usuário
I'm experienced in shell programming and with ssh - this is what I do everyday on my job. Here in Germany it's after midnight now, that's why i terminate this message with GOOD NIGHT :-)
$10 USD em 1 dia
0,0 (0 avaliações)
0,0
0,0
Avatar do Usuário
Hi! I have a large experience in LAMP environments. I am new here on freelancer, so I want to gain reputation and get a good opinion from you.
$25 USD em 3 dias
0,0 (0 avaliações)
0,0
0,0
Avatar do Usuário
I've done this before. Contact me and I'll teach you how to escape arguments with ssh, or with any unix command, for that matter.
$15 USD em 1 dia
0,0 (0 avaliações)
0,0
0,0
Avatar do Usuário
working in linux,And handing the servers over ssh and also handle the mysql database for the main website of the company.
$20 USD em 3 dias
0,0 (0 avaliações)
0,0
0,0
Avatar do Usuário
I know what to do. Firstly, you must have permission to execute mysql on remote host. And Secondly, you have some mistakes in you command. It must be like this: ssh username@HOST "mysql -u root -e 'Select ''123'' as ''text'', users.* from users;' exim"
$10 USD em 3 dias
0,0 (0 avaliações)
0,0
0,0

Sobre o cliente

Bandeira do(a) UNITED STATES
Pasadena, United States
5,0
17
Método de pagamento verificado
Membro desde jun. 22, 2013

Verificação do Cliente

Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.