Results 1 to 7 of 7

Thread: Help with shell script

  1. #1
    Join Date
    Mar 2009
    Location
    Gym, UK -> Norfolk
    Beans
    156
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Help with shell script

    Target to make script which will create mysql user.
    I have mysql commands
    PHP Code:
    mysql -u userName -p

    insert into db 
    (hostdbuserselect_privvalues ('localhost''customers''kayon''Y'); 
    Im not sure how to combine it in to shell script.
    Please help..
    Last edited by Spikerok; November 28th, 2009 at 12:02 AM.

  2. #2
    Join Date
    Sep 2009
    Beans
    88

    Re: Help with shell script

    you could put it into a .sql file and do something like:

    Code:
    mysql -u username -ppassword databasename < script.sql
    note the spacing on the password switch

  3. #3
    Join Date
    Aug 2006
    Beans
    70

    Re: Help with shell script

    You should also be able to do the following:

    Code:
    mysql -u userName -ppassword -e 'insert into tablename (host, db, user, select_priv) values ('localhost', 'customers', 'kayon', 'Y')' databasename

  4. #4
    Join Date
    Mar 2009
    Location
    Gym, UK -> Norfolk
    Beans
    156
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Help with shell script

    can't believe that it's so simple...
    Is their any thing alse I should include?
    Last edited by Spikerok; November 28th, 2009 at 12:40 AM.

  5. #5
    Join Date
    Sep 2009
    Beans
    88

    Re: Help with shell script

    It would be better to handle database scripts with a python or php script... but that way works fine too

  6. #6
    Join Date
    Mar 2009
    Location
    Gym, UK -> Norfolk
    Beans
    156
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Help with shell script

    I will be using PHP to give values to shell script.
    User will enter data in browser which will transferred to script.
    Script will start and complete given task.

  7. #7
    Join Date
    Aug 2006
    Beans
    70

    Re: Help with shell script

    Quote Originally Posted by Spikerok View Post
    I will be using PHP to give values to shell script.
    User will enter data in browser which will transferred to script.
    Script will start and complete given task.
    There is no reason to do it that way. PHP can do those things directly without having to call a shell script. Just search for "PHP MySQL" and you will find lots of great tutorials with simple examples.

Bookmarks

Posting Permissions

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