Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Location
    Singapore
    Posts
    200

    Unanswered: mysql query in a script

    --------------------------------------------------------------------------------

    Hi guys,

    I would like to run a shell script.I want to assign a values from a mysql query within a shell script.As

    t = ./mysql -D database -e "select count(*) from tablename;"

    so t can contain the number of records in the table and I can run futher in a loop.

    The part where I get stuck is when I run the script it says

    test_scrpt.sh: line 25: -D: command not found


    Please help me on this.Is there any other way I can do this.

    Thnaks
    micky

  2. #2
    Join Date
    Jun 2004
    Posts
    20
    Use backquotes for the command to be executed as mentioned below

    t=`mysql -D database -Be "select count(*) from tablename;" |grep -v count`

    HTH
    cheers
    Jc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •