I want to run some commands and get the output into a mysql database.
I want to run the df cmd into a text file, then import it into my db sysinfo using a bash script.
My table "df" has the following 9 fields:
server, filesystem, size, used, available, useperc, mounted, date, time
cmd for df creates it in a comma separated output.
bash script for loading data:
Unfortunately this is not working and I only get the first line imported.
Can some one show me how to fix this script, I think it may be to do with the line terminators but can't find a solution.
I would also like to prepend the host name for field 1 and the date and time in the last 2 fields.
I'm very new to sql would really apreciate some help and advice.
Hi all,
I am running this script on Mandrakelinux release 10.1, 2.6.8.1-12mdksmp #1 SMP
I have also installed 'expect' separately.
I have created an Rsync script, but before any Rsync command does run, a MySql dump must be done first, and I am battling a bit to pass the MySql password from... (2 Replies)
I'm trying to export a mysql query to a .csv file, right now I'm running a successful query like:
us_id=`mysql -u $USER_NAME --password=$PASSWORD -D "databasename" \
-e "SELECT * \
FROM databasename.table \
WHERE somefield >0 AND otherfield ='$ctry' \
ORDER BY... (1 Reply)
Ok the issue I have is a bit complicated, for me, and my understanding of shell programming and bash is non-existent.
Background: I do web development for a team of programmers that make custom kernels for the Android OS. The guys are using a bash script (through gerrit or github, like I said... (4 Replies)
Can someone tell me the syntax to run a shell script from within MySQL? I know there is a way to do it, but I can't remember the syntax. I thought it was something like:
mysql> \. /user/myscript;
but I get this error:
Failed to open file '/user/myscript;', error: 2
Please help!... (4 Replies)
Hi,
I'm having problems with a script which some of you helped me with last week. It's a script to check the status of orders in an SQL database, and if the count(*) is zero, then the script stops. If it's non-zero, the script echos the result to a file and then in cron, I cat the file and mail... (3 Replies)
Hello!
I've got script to write. It should read databases (names, volumes) from table testdatabase and compares it to actually existing databases in /var/lib/mysql/. If there is no informations about database in table - we should see information "There is no declared informations about database... (1 Reply)
Hi,this doesnt give any output
mysql -uroot -phruti2 -B -e "use WebNmsDB;select HEADERINDEX from meas_headers where CLLI= '$clli' and IVALSTART>'$ivalstart' and IVALSTART<'$ivalend' and RPTTYPE='$rpttype';" > asdf.txt
This generates "good" output
mysql -uroot -phruti2 -B -e "use... (1 Reply)
1. bash
-bash escape rules, esp. ',",
-how to use Ctrl+R reverse cmd search with regex?
2. mysql
-how to use grep in mysql
3. php
-why !0 is not evaluated to true? what's its value
-php getopt: what if there is duplicate in cmdline args (2 Replies)
I think(hope) I've got a simple one - I just need to send an email if a mysql query returns any results (ideally - it will never match).
Currently I just pipe the mysql query output to the mail program, but of course that emails regardless of the output( and I check this every 10 minutes from... (5 Replies)
Hi,
Below is my code to execute mysql statement , how to save the output to a file ?
#!/usr/bin/bash
#Script to run automated sql queries
#Declaring mysql DB connection
MASTER_DB_USER='root'
MASTER_DB_PASSWD='root'
MASTER_DB_PORT=3306
MASTER_DB_HOST='localhost'... (1 Reply)