Hend
Hend

Reputation: 599

Bash - Retrieve data from mysql for http call

I'm new to bash scripting so would need your help. I am trying to get data from mysql database and use the parameters for a http call. For example,

$string = data from mysql

http://www.company.com/organizer/$string

How do I retrieve data from mysql and store in a string then use it for the http call? I need to execute the http url like using it in the browser.

My current codes are as:

#!bin/bash
$string = mysql Company<<EOFMYSQL
select name from HR;
EOFMYSQL

Upvotes: 0

Views: 348

Answers (2)

Jasonw
Jasonw

Reputation: 5064

how about the following?

string="`mysql -uusername -ppassword dbname -e 'select * from foo;'`"
url="http://www.company.com/organizer"
url="$url/$string";
wget "$url"

Upvotes: 1

SiegeX
SiegeX

Reputation: 140417

You want to use command substitution via $()

#!/bin/bash

string=$(mysql ...)
echo "http://www.company.com/organizer/$string"

Upvotes: 1

Related Questions