Closed Thread
Results 1 to 4 of 4

Thread: Automating MySQL with a shell script

  1. #1
    DarkLordoftheMonkeys's Avatar
    DarkLordoftheMonkeys is offline Programming Professional
    Join Date
    Oct 2009
    Location
    Massachussets
    Posts
    255
    Blog Entries
    56
    Rep Power
    11

    Automating MySQL with a shell script

    I want to create a bash shell script to automate MySQL by using a here-document, like this:

    Code:
    mysql << EndOfScript;
    USE Personal_Files
    INSERT INTO Daily
    VALUES ('$year-$month-$day',NULL,NULL,NULL);
    EndOfScript;
    Will I be able to do this without messing up my database? I have valuable information in it and I don't want to lose it. I've only ever used a here-document for ed before, not for an application that doesn't operate on files.
    Life's too short to be cool. Be a nerd.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    DarkLordoftheMonkeys's Avatar
    DarkLordoftheMonkeys is offline Programming Professional
    Join Date
    Oct 2009
    Location
    Massachussets
    Posts
    255
    Blog Entries
    56
    Rep Power
    11

    Re: Automating MySQL with a shell script

    Never mind. I just found a way to write scripts in MySQL.
    Life's too short to be cool. Be a nerd.

  4. #3
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: Automating MySQL with a shell script

    which way do you mean?
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

  5. #4
    DarkLordoftheMonkeys's Avatar
    DarkLordoftheMonkeys is offline Programming Professional
    Join Date
    Oct 2009
    Location
    Massachussets
    Posts
    255
    Blog Entries
    56
    Rep Power
    11

    Re: Automating MySQL with a shell script

    I put the commands and queries I wanted to use in a batch file with the extension .mysql, then ran the batch file by typing sudo mysql < script.mysql in the bash terminal. I learned how to do that from the MySQL documentation at dev.mysql.com.
    Life's too short to be cool. Be a nerd.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [HELP] convert Perl script to Bash shell script
    By Egypte in forum Linux Programming and Scripting
    Replies: 2
    Last Post: 04-24-2011, 05:37 PM
  2. Please Kindly Help me with shell script
    By alice06 in forum C and C++
    Replies: 1
    Last Post: 10-21-2010, 08:09 AM
  3. Shell Script Help!
    By SeanStar in forum Linux Programming and Scripting
    Replies: 6
    Last Post: 08-12-2010, 05:20 PM
  4. Making a GUI in a Shell Script
    By dargueta in forum Linux Tutorials, Guides and Tips
    Replies: 15
    Last Post: 07-26-2010, 06:56 PM
  5. Replacing with Shell Script and VI
    By Nightracer in forum General Programming
    Replies: 2
    Last Post: 11-05-2006, 07:18 AM

Tags for this Thread

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