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










1















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.










share|improve this question






















  • 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
















1















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.










share|improve this question






















  • 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














1












1








1








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.










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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


















  • 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

















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











1 Answer
1






active

oldest

votes


















2














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.






share|improve this answer























    Your Answer








    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
    );



    );













    draft saved

    draft discarded


















    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









    2














    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.






    share|improve this answer



























      2














      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.






      share|improve this answer

























        2












        2








        2







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        Jeff SchallerJeff Schaller

        44.4k1162143




        44.4k1162143



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

            Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

            Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.