How do I capture this mysql output message in a variable? The Next CEO of Stack OverflowHow do I set an environment variable for sudo in MacOS?Running `sudo /sbin/service mysqld start` causes system to crashCan't seem to connect to my Debian Mysqli Server?Bash Mysql Command Substitution Login FailureMariaDB client has no prompt in Emacs sql-modeSilent MySQL Server installationvariable not being read correctlyBash Shell URL built with variables are missing after inserting behind http://How can I automatically target the output of a download scriptDROP USER IF EXISTS syntax error in MySQL CLI
Traveling with my 5 year old daughter (as the father) without the mother from Germany to Mexico
Audio Conversion With ADS1243
Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?
Is it ever safe to open a suspicious HTML file (e.g. email attachment)?
Is it okay to majorly distort historical facts while writing a fiction story?
Is it ok to trim down a tube patch?
Purpose of level-shifter with same in and out voltages
how one can write a nice vector parser, something that does pgfvecparseA=B-C; D=E x F;
Do scriptures give a method to recognize a truly self-realized person/jivanmukta?
Is it convenient to ask the journal's editor for two additional days to complete a review?
What is the difference between "hamstring tendon" and "common hamstring tendon"?
Won the lottery - how do I keep the money?
Could a dragon use its wings to swim?
Why did early computer designers eschew integers?
What is the process for purifying your home if you believe it may have been previously used for pagan worship?
How do I fit a non linear curve?
Vector calculus integration identity problem
What does "shotgun unity" refer to here in this sentence?
What flight has the highest ratio of timezone difference to flight time?
Cannot shrink btrfs filesystem although there is still data and metadata space left : ERROR: unable to resize '/home': No space left on device
It is correct to match light sources with the same color temperature?
Film where the government was corrupt with aliens, people sent to kill aliens are given rigged visors not showing the right aliens
Why don't programming languages automatically manage the synchronous/asynchronous problem?
From jafe to El-Guest
How do I capture this mysql output message in a variable?
The Next CEO of Stack OverflowHow do I set an environment variable for sudo in MacOS?Running `sudo /sbin/service mysqld start` causes system to crashCan't seem to connect to my Debian Mysqli Server?Bash Mysql Command Substitution Login FailureMariaDB client has no prompt in Emacs sql-modeSilent MySQL Server installationvariable not being read correctlyBash Shell URL built with variables are missing after inserting behind http://How can I automatically target the output of a download scriptDROP USER IF EXISTS syntax error in MySQL CLI
I have this line in my script:
mysqlinsert=$(/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot --password=notmyrealpassword << EOF
$mysqlrun)
Despite what it returns, the variable $mysqlinsert
is always empty. I tried using -n
(disables output buffering) for mysql and putting EOF
after $mysqlrun
but neither worked.
bash mysql variable
add a comment |
I have this line in my script:
mysqlinsert=$(/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot --password=notmyrealpassword << EOF
$mysqlrun)
Despite what it returns, the variable $mysqlinsert
is always empty. I tried using -n
(disables output buffering) for mysql and putting EOF
after $mysqlrun
but neither worked.
bash mysql variable
the usual suspects would be: (1) there was no output, and/or (2) the output went to stderr instead of stdout. During the script's execution, did any mysql output accumulate to your screen?
– Jeff Schaller♦
2 days ago
Another option would be that the current user could not execute/Applications/MAMP/Library/bin/mysql
, resulting in yet more stderr and an empty variable.
– Jeff Schaller♦
2 days ago
@JeffSchaller, yes I see the output on my screen. It's likely that the output went to stderr, which I tried to change with2>&1
, it didn't work (but I may have placed this redirect in the wrong place? I put it after$mysqlrun
)
– DisplayName
2 days ago
add a comment |
I have this line in my script:
mysqlinsert=$(/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot --password=notmyrealpassword << EOF
$mysqlrun)
Despite what it returns, the variable $mysqlinsert
is always empty. I tried using -n
(disables output buffering) for mysql and putting EOF
after $mysqlrun
but neither worked.
bash mysql variable
I have this line in my script:
mysqlinsert=$(/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot --password=notmyrealpassword << EOF
$mysqlrun)
Despite what it returns, the variable $mysqlinsert
is always empty. I tried using -n
(disables output buffering) for mysql and putting EOF
after $mysqlrun
but neither worked.
bash mysql variable
bash mysql variable
asked 2 days ago
DisplayNameDisplayName
4,63594782
4,63594782
the usual suspects would be: (1) there was no output, and/or (2) the output went to stderr instead of stdout. During the script's execution, did any mysql output accumulate to your screen?
– Jeff Schaller♦
2 days ago
Another option would be that the current user could not execute/Applications/MAMP/Library/bin/mysql
, resulting in yet more stderr and an empty variable.
– Jeff Schaller♦
2 days ago
@JeffSchaller, yes I see the output on my screen. It's likely that the output went to stderr, which I tried to change with2>&1
, it didn't work (but I may have placed this redirect in the wrong place? I put it after$mysqlrun
)
– DisplayName
2 days ago
add a comment |
the usual suspects would be: (1) there was no output, and/or (2) the output went to stderr instead of stdout. During the script's execution, did any mysql output accumulate to your screen?
– Jeff Schaller♦
2 days ago
Another option would be that the current user could not execute/Applications/MAMP/Library/bin/mysql
, resulting in yet more stderr and an empty variable.
– Jeff Schaller♦
2 days ago
@JeffSchaller, yes I see the output on my screen. It's likely that the output went to stderr, which I tried to change with2>&1
, it didn't work (but I may have placed this redirect in the wrong place? I put it after$mysqlrun
)
– DisplayName
2 days ago
the usual suspects would be: (1) there was no output, and/or (2) the output went to stderr instead of stdout. During the script's execution, did any mysql output accumulate to your screen?
– Jeff Schaller♦
2 days ago
the usual suspects would be: (1) there was no output, and/or (2) the output went to stderr instead of stdout. During the script's execution, did any mysql output accumulate to your screen?
– Jeff Schaller♦
2 days ago
Another option would be that the current user could not execute
/Applications/MAMP/Library/bin/mysql
, resulting in yet more stderr and an empty variable.– Jeff Schaller♦
2 days ago
Another option would be that the current user could not execute
/Applications/MAMP/Library/bin/mysql
, resulting in yet more stderr and an empty variable.– Jeff Schaller♦
2 days ago
@JeffSchaller, yes I see the output on my screen. It's likely that the output went to stderr, which I tried to change with
2>&1
, it didn't work (but I may have placed this redirect in the wrong place? I put it after $mysqlrun
)– DisplayName
2 days ago
@JeffSchaller, yes I see the output on my screen. It's likely that the output went to stderr, which I tried to change with
2>&1
, it didn't work (but I may have placed this redirect in the wrong place? I put it after $mysqlrun
)– DisplayName
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
If the command is sending the output you want to stderr, then redirect the command's stderr inside the command substitution:
mysqlinsert=$(/Applications/MAMP/Library/bin/mysql ... 2>&1 << EOF ...)
#
# /______addition____
... where I've elided some parameters to focus on the change I'm suggesting.
add a comment |
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509494%2fhow-do-i-capture-this-mysql-output-message-in-a-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If the command is sending the output you want to stderr, then redirect the command's stderr inside the command substitution:
mysqlinsert=$(/Applications/MAMP/Library/bin/mysql ... 2>&1 << EOF ...)
#
# /______addition____
... where I've elided some parameters to focus on the change I'm suggesting.
add a comment |
If the command is sending the output you want to stderr, then redirect the command's stderr inside the command substitution:
mysqlinsert=$(/Applications/MAMP/Library/bin/mysql ... 2>&1 << EOF ...)
#
# /______addition____
... where I've elided some parameters to focus on the change I'm suggesting.
add a comment |
If the command is sending the output you want to stderr, then redirect the command's stderr inside the command substitution:
mysqlinsert=$(/Applications/MAMP/Library/bin/mysql ... 2>&1 << EOF ...)
#
# /______addition____
... where I've elided some parameters to focus on the change I'm suggesting.
If the command is sending the output you want to stderr, then redirect the command's stderr inside the command substitution:
mysqlinsert=$(/Applications/MAMP/Library/bin/mysql ... 2>&1 << EOF ...)
#
# /______addition____
... where I've elided some parameters to focus on the change I'm suggesting.
answered 2 days ago
Jeff Schaller♦Jeff Schaller
44.4k1162143
44.4k1162143
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509494%2fhow-do-i-capture-this-mysql-output-message-in-a-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
the usual suspects would be: (1) there was no output, and/or (2) the output went to stderr instead of stdout. During the script's execution, did any mysql output accumulate to your screen?
– Jeff Schaller♦
2 days ago
Another option would be that the current user could not execute
/Applications/MAMP/Library/bin/mysql
, resulting in yet more stderr and an empty variable.– Jeff Schaller♦
2 days ago
@JeffSchaller, yes I see the output on my screen. It's likely that the output went to stderr, which I tried to change with
2>&1
, it didn't work (but I may have placed this redirect in the wrong place? I put it after$mysqlrun
)– DisplayName
2 days ago