Programming :: Shell Script To Get Count Of Records In A Mysql Table?

Oct 23, 2010

I'm using MYTHTV with AT&T's U-Verse system. AT&T apparently turns off the set-top box if the box doesn't receive any commands after some number of hours. When this happens the box takes so long to turn on that it doesn't process the lirc IR channel change command. I've rewritten my channel changer to add a lockfile, and added a cron entry to kick off an entry to just "ping" the set-top box once an hour. But, OK, I'd like to play the bandwidth saving game and not do this if there isn't anything in the "record" table.

So, how would I write a script that will check the number of rows in the "record" table in the "mythconverg" database and exit if there are zero rows? I'm afraid I don't know how to even start this. Here is my "keepalive.sh" script that does the pinging:

Code:
#!/bin/sh
#if there are no rows in the record table, just exit this script
# lock the lockfile - MUST be same one as channel lock
while [ `lockfile "/tmp/mythchanlock.lck"` ]

[Code]....

View 3 Replies


ADVERTISEMENT

Programming :: DBD::mysql::st Execute Failed: Column Count Doesn't Match Value Count At Row 1

Feb 24, 2010

I have the following perl/DBI script:

Quote:

#!/usr/bin/perl
use DBI;
my ($db, $user, $pw) = ('dbname', '****', '***********');
my $dbh = DBI->connect("DBI:mysql:$db",$user,$pw) or die "Cannot connect to $db: $DBI::errstr

[code].....

The error message is

[Wed Feb 24 13:03:27 2010] myscript.cgi: DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at myscript.cgi. [Wed Feb 24 13:03:27 2010] myscript.cgi: DBI::db=HASH(0x8a30c60)->errstr

View 2 Replies View Related

Programming :: Count Number Of CD-ROMs On A System Using Shell Script

Apr 7, 2010

I am trying to get the count of number of CD-ROMs attached with my Linux system using a bash shell script. I have decided to use the following method for it:

Code:
debian:~# cat /proc/sys/dev/cdrom/info | grep "drive name:"
drive name: sr0 hdb

So basically I know that there are two CD-ROMs attached to the system. Now there can be three also like this:

Code:
debian:~# cat /proc/sys/dev/cdrom/info | grep "drive name:"
drive name: sr0 sr1 hdb

All I want to do is in my shell script to get the count of the devices in a variable using the above command.

View 2 Replies View Related

Programming :: PHP Ignores One MySQL Table But Not Others?

Sep 23, 2010

I have just run into a baffling error. I have a database set up in MySQL with six tables. My PHP based website performs queries of all kinds on these tables (SELECT, INSERT, UPDATE, DELETE). On my most recently setup table, the "Orders" table, I am able to perform queries from the server, as well as from my PHP MySQL Admin interface, but all activity from my webpage states that the Orders table does not exist. All other tables are running fine. I have tried rewriting the query script, checked for case sensitivity problems, even cut and pasted other working scripts in place, changing the table and field names as needed. No success. What could cause a single table to not show up like this?

View 2 Replies View Related

Programming :: Unable To Delete A Table In MySQL?

Oct 17, 2010

A sed mishap prior to a database import left me with a table name with, eh, well, this: Code: mysql> show tables;

+-------------------+
| Tables_in_someday |
+-------------------+
| day20101016 |
| day20101017); |
+-------------------+

I've corrected the sed mishap and imported the database the way it was intended Code: mysql> show tables;

+-------------------+
| Tables_in_someday |
+-------------------+
| day20101016 |
| day20101017); |
| day20101017 |
+-------------------+

But I can't seem to drop the table day20101017); because no matter how I seem to escape it it errors.

View 1 Replies View Related

Programming :: MySQL And PHP - Table Column With Multiple Values?

Dec 1, 2008

I am writing a script to mine data from my game server logs which are going to mysql. My first question is syslog-ng is sticking $msg into one colum it self, $msg tends to be a long string here are a few examples:

cn name team frag death flags role host.
0 Maik CLA 2 0 0 normal *.70.233.118.
1 lizardncd RVSF -1 3 0 normal
[*.22.247.40] lizardncd fragged Maik.

And they are not always in the same format, How could I parse this data to do something useful, like creating a user stats page with frag counts and flag counts. Should I create a script that runs in a cronjob that parses this data to a new table maybe once a day. Even then the $msg string value is random and I am thinking in terms of awk.

Second. I would like to keep track of what ip's are using what nicknames. Kinda in the sense of and ip associated to a array of names that have been used on that ip address so I can keep track of users. How would this work logically with a mysql db, could a column allow multiple values, then loadable into an array, which then can add, remove, and store to mysql.

View 1 Replies View Related

Programming :: Using Perl To Update Mysql Table On Certain Event?

Feb 6, 2011

I'd like to use a perl script to update a fields in mysql database when pianobar (command line pandora radio player) starts a new song. Pianobar has the ability to run a script based on events, I'd like to take advantage of and use perl toparse the artist,song,album and update the corresponding fields. Then later retrieve them and display them with php/html. I am by no means proficient with perl. I started to use bash, but it looks like perl will be much more efficient and and less time consuming.

Code:
#! /usr/bin/perl -wT
use strict;

[code]...

View 2 Replies View Related

Programming :: How To Sort Two MySQL Table On Date Or Time Column

Jul 27, 2011

I have two different table in a database in mysql that has no share key with each other and I want to sort them with each other on their date time column I mean when I sort it row X of table A that is older that row Y of table B comes earlier.

View 3 Replies View Related

Programming :: Perl: Compare CGI Input With Data From A MySQL Table?

Nov 19, 2008

I have this program:

#! /usr/bin/perl
use DBI ;
use strict ;

[code]....

and I get this error simply running the program from the command line: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at ./submit.cgi line 24.

is this the right syntax to use, both, for this line:

my (@param) = $cgi->param("firstname","lastname","type") ;

as well as this one:

$sth=$dbh->prepare ("SELECT firstname,lastname,type FROM dts WHERE firstname LIKE $param[0] AND lastname LIKE $param[1] and type LIKE $param[2]" );

or should there be quotes around the $param[0] or something? (also is it $param[0] or $param(0)?)

View 1 Replies View Related

Programming :: Shell Script To Table RAW Device Values?

Mar 30, 2011

I'm working on a script to table the outputs of various commands that depend on each other. The commands are these:

Code:

[root@kybsdc2 ~]# raw -q /dev/raw/raw1
[root@kybsdc2 ~]# sginfo -a /dev/dm-5 | grep Serial
[root@kybsdc2 ~]# multipath -ll

which give these outputs:

Code:

#/dev/raw/raw1:bound to major 253, minor 5
#Serial Number 'P3e8hZWrsSeX'
#netapp (360a9800050336538685a577273536558) dm-5 NETAPP,LUN
[size=1.0G][features=1 queue_if_no_path][hwhandler=0][rw]

[code]....

Also the RAW13 device has completely wrong output due to 1 occurring more times throughout the sequence causing more information to be displayed then needed. The last point is if I could somehow remove the '' in the serial number outputs and the = sign from the device sizes. I guess I will have to either put a whole lot of logical IF or CASE statements in but somehow I need to streamline and make this code dynamic!

View 8 Replies View Related

Programming :: Importing MYSQL Table From Text File Wo Column Delimiters?

Jun 13, 2011

I am trying to import a data file from old DOS application into MYSQL table The file is clear text file with fixed-width columns, without column delimiters

Example file :
Code:
4444333666666
2222666555555
iiiiwwwcccccc

[Code]...

View 3 Replies View Related

Programming :: PHP Auto Removes Stale Sessions On It's Own But Doesn't Remove From MYSQL Table

Aug 24, 2010

I know PHP auto removes stale sessions on it's own, but that doesn't remove them from the MYSQL table. So I was gonna make a cron script that ran once every hour that removed any MYSQL shopping cart item from the table if the original session_id that created it does not exist anymore.

From my understanding a session_id is an "actual" file located somewhere on the harddisk (is it not? correct me if I'm wrong), so I was going to do a simple check for each item in the shopping cart to check for it's original session file, if it didn't exist on the harddisk, then simply remove it from the mysql table.

View 1 Replies View Related

Programming :: Make Shell Script To Use Sqlplus To Update Some Database Table?

Feb 8, 2010

How can I make shell script to use sqlplus to update some database table? This is what I'd like to make:

- login to db server (I have create ssh-keygen to bypass the login session)
- login sqlplus / as sysdba
- update status set status='END' where status='BEGIN';
- commit;
- quit;

I'm using oracle 10g database and SLES 9.0

View 3 Replies View Related

OpenSUSE :: Kmail Akonadi And Mysql Errors - Can't Open And Lock Time Zone Table: Table

May 3, 2010

Kmail 1.13.2 Problem on startup, error is from nepomuk, data storage. "cannot find Redland backend, nepomuk is disabled until fixed. Also see the following error from the akonadi console:

100503 10:00:15 [Note] Plugin 'ndbcluster' is disabled.
100503 10:00:15 InnoDB: Started; log sequence number 0 31413862
100503 10:00:15 [Warning] Can't open and lock time zone table: Table
'mysql.time_zone_leap_second' doesn't exist trying to live without

[code]....

View 2 Replies View Related

Server :: Mysql 'Table 'mysql.user' Doesn't Exist'?

Aug 2, 2010

I'm trying to setup wordpress on my server, which of course I need mysql for. I setup a database the other day, which worked perfectly, but I had to start again as I put some information in wrong. Now, I can create a database fine, but when I run

Code:
GRANT ALL ON wordpress.* TO wordpress@localhost IDENTIFIED BY "password";
I get the output:

[code]...

View 13 Replies View Related

Server :: A Script To Shutdown A Service When A Sybase Table Reads Over A Certain Count?

Aug 3, 2009

Someone at work has requested if i can find out anything on the above.Been googling around as well as i have only been using Linux for 2 months now.

basically there is a SYBASE ASE installation on the server, which a tomcat based website references.They want the service to stop once a certain row limit is reached in the table.

I know i have to do a count statement on the sybase table from ISQL.But how can i create the action "service website stop" once the count value reaches 4000 ?

View 2 Replies View Related

Programming :: Scenario For Call Shell Function From Mysql?

Apr 18, 2011

I am trying a scenario for calling a shell script when ever a trigger is called. Can some one guide me how to achieve this scenario. Also it should passes the value from the table to the shell script. Can some one explain me along with the example.

View 2 Replies View Related

Programming :: Creating Script For Mysql Connection From Shell?

Jul 8, 2011

I'm creating script to connect to mysql and perform function. I'm into process in querying mysql from shell. Here is the content of a sample script:

Code:
#!/bin/bash
USER=scripter
PASS=test123
DB=test_scripts

View 2 Replies View Related

Fedora Servers :: FC5 > F12 - ERROR: Column Count Of Mysql.db Is Wrong

Jan 31, 2010

Target F12 mysql - 5.1.42-2
Source FC 5 mysql - 5.0.27-1

I've put SElinux into permissive mode as it was practically denying anything that moved. Both installed from the standard repos. I used mysql-administrator to create a backup of the FC5 server (all databases/tables) and transferred it to the new system. I restored it onto that machine and double checked that my standard admin user (full privs) was present and let me log in to make changes. All good so far.

So I copied over my files from my sites, point a browser at them and I get nothing, not even errors. Now it's a long while since I set the original up and have probably forgotten something simple but despite making the error output more verbose I can't seem to track anything down other than:

[Code]....

So it suggests my tables are invalid/trashed but I can't seem to figure out why. The original server is still running happily so I'm not in any rush to fix this, I'll keep plodding, Phpinfo reveals a normal operational php setup, so i think that side of the sites is functional. Apache test pages work on blank virtual hosts but viewing my sites reveals the favicon working fine but otherwise comepletely blank pages (zero output, even source). I tried running the page as a raw CLI input to the php package using php index.php and php returned nothing, logged nothing unusual but sat with my CPU at 100%, unsure if that is related.

View 1 Replies View Related

General :: Count Multiple Objects In Shell Script?

Jul 21, 2010

Trying to count the number of oracle instances on HPUX 11.23 - using ksh. I have multiple instances running and I would like to have a count for how many processes for eachinstance.Example, run the 'ps -efu oracle' command and for each instance increment a counter. So I am looking forINT1=# INT2=# INT3=# ... INTn=#I keep thinking a 'do-while' or some type of 'while' loop but I am missing something, somewhere

View 2 Replies View Related

General :: Create A New Mysql User And A Mysql Database At The Shell Prompt?

Aug 7, 2010

How do I create a new mysql user and a mysql database at the shell prompt?

View 1 Replies View Related

General :: Write Shell Script Which Can Take Number Of Files And Count Total Rows From All CSVs?

Oct 8, 2010

I need to write shell script which can take number of files and count total rows from all CSVs and display total number of rows counted in all files. Is there any possibility of doing that using shell script and if yes then how.

View 4 Replies View Related

Server :: Replicate 1 Table In Mysql To Different IP?

Aug 7, 2009

I have 2 servers, 1 running a web server on 1 IP address,the other server running a proxy on a different IP address. I intend to change and update the ncsa file with usernames and passwords from a mysql table.Is there a way to replicate 1 table from the webserver to the proxy server databases and then run a cronjob? The cron will simply delete unused usernames and add new ones.Is there a better way of doing this? I don't want to run the webserver on the proxy server for security and also for performance.

View 2 Replies View Related

Programming :: Loop Through Records In A File?

Apr 23, 2011

I want to loop through the records in the below file (homedir.temp)
/home/user1
/home/user2
/home/user3

I want to do the following activities with each record1. du -s - to get the total usage for that directory (my variable name is SIZE)2. divide SIZE by du -c for /home to get the percentage of usage. (my variable name is PER)3. write the directory, SIZE, PER to a filePROBLEMI am using the below for loop: for record in homedir.tempthe mentioned activitiesdonehe above is not looping through the records. It does the first record perfectly and exits the loop.

View 14 Replies View Related

Ubuntu Servers :: Import Table.sql To Mysql?

Jun 8, 2011

I am trying to install some program: rosinfo: - Create mysql database for rosinfo - Create table hosts, locks. Use file docs/rosinfo.sqlAnd I need to create table hosts, locks, using file rosinfo.sql. I have that file, but dont know what to do with it.

View 1 Replies View Related

Ubuntu Servers :: [MySQL] Where To Create A New Table

Jul 13, 2011

I've started a webserver at 127.0.0.1:**** I want to be able to use a database for this server. Which schema do I use to add a new table to? Do I create a new Schema altogether?

View 5 Replies View Related

Server :: Removing Old Table Data From MySQL?

Jul 6, 2009

When a user logs into my webmail application, it creates entries in a table on MySQL called "identities" which works great however once the user is deleted fro Linux with the "userdel -r" command, the data still sits in MySQL. My question is how I can I remove the table data from old users? It appears as show below:

[code].....

View 1 Replies View Related

Software :: Mysql 5.0 - What Is The Use Of UNION=() In CREATE TABLE

Feb 24, 2009

What is the use of UNION=() in CREATE TABLE?

Code:

ENGINE=MRG_MyISAM DEFAULT CHARSET=utf8 UNION=();

I have been given some code and could not explain why it's err's out. Checked the mysql 5.0 manual but nothing[URL]. It only explains using UNION in a SELECT statement which I understand. If I drop off UNION=() then CREATE TABLE works fine.

View 4 Replies View Related

Programming :: Load Multiple Records Into SQLite?

Nov 19, 2008

I am using SQLite as my database for some portable cross platform applications I am working on with REALBasic as my IDE. I have an old Sybase 8.0 database that I can access via Microsoft Access and thereby extract the data I need from each table.

Now I know I can create .csv files from each table and load them into SQLite using the import tool, but then I can't define the primary key and other field attributes. So the other option is to load each file via SQL.

Now with most SQL editors I can create multiple queries and they will run just fine. But I can't seem to do that with the SQLite interfaces. I can paste multiple queries but I can only run one at a time. And by that I mean I have to click run.

Ummm that's not acceptable since my biggest table contains over 600,000 records. I have the queries all written, that was easy using a simple interface I wrote in Access.

Code:
INSERT INTO tblMeters(recordId,meterId,meterName,meterSerNum,registerSerNum,mxuSerNum,meterType,manufacture,meterModel,readType,groupId,multiplier,rollover,vendorId,xfrmerCode,bldgCode,CATEGORY,energyType,unitOfMeasure,location,access,comments,dateInstalled,dateCalibrate,pipeSizeIn,pipeSizeOut,elecMeterSpecs)

[Code]...

So is there another method I can use? I can't seem to find anything relating to my particular question at the SQLite web site

View 3 Replies View Related

Programming :: Parse A File Containing Billions Of Records?

Nov 17, 2010

I have to parse a file containing billions of records and populate them in the Data structure. I have used a lot of C++ class and creating objects of the class I am storing the information retrieved by parsing the file.

Now as the file become huge and number of objects become very large my code is getting bad_alloc error as it is not finding any space avalable in the heap for allocating new object.

Is there any way to parse the file?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved