Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> Stuck with a cron job
oracle765
post Apr 1 2014, 02:53 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 3
Joined: 8-January 14
Member No.: 18,617



Hi professionals I hope I am posting in the right forum

I have a feed.sh file which I run in a cron job to try and import a tab delimited text file into MySQL database. Problem is I am new to Linux and I am fairly stuck so if someone could point my in the right direction that would be great

Here is the .sh file which I am trying to run, it seems to grab the text file ok and connect to the db but then produces errors

CODE
#Get price retailers list
/usr/bin/wget -O "/home/oracle765/public_html/feed/getprice.txt" 'http://www.getprice.com.au/affinityclick/ShopsList.aspx?Pass=1iob2kjd&ref=cc';


$dbh = mysql -u compareandchoose -p Comparechoose12 -h mysql.compareandchoose.com.au mydatabase # < /home/oracle765/public_html/feed/getprice.txt

$SQL = "LOAD DATA INFILE '/home/oracle765/public_html/feed/getprice.txt' REPLACE INTO TABLE getpriceretailer FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' (id,name,url,logo,rank,products,List)";

$dbh->prepare($SQL);
$dbh->execute;
$dbh->finish;
$dbh->disconnect;


and here is the email error I receive

CODE
2014-04-01 00:29:02 (1.14 MB/s) - /home/oracle765/public_html/feed/getprice.txt saved [244130/244130]

/home/oracle765/public_html/scripts/feedimport.sh: line 14: =: command not found
/home/oracle765/public_html/scripts/feedimport.sh: line 16: =: command not found
/home/oracle765/public_html/scripts/feedimport.sh: line 18: syntax error near unexpected token `('
/home/oracle765/public_html/scripts/feedimport.sh: line 18: `$dbh->prepare($SQL);'
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
michaelk
post Apr 1 2014, 08:28 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



Is this your entire script? I assume it is bash.

I have been trying to determine what language or where the following came from:
$SQL = "LOAD DATA INFILE '/home/oracle765/public_html/feed/getprice.txt' REPLACE INTO TABLE getpriceretailer FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' (id,name,url,logo,rank,products,List)";
$dbh->prepare($SQL);
$dbh->execute;
$dbh->finish;
$dbh->disconnect;

I do not use mysql but those statements will not run in bash.

You can run multiple mysql statements via something like this:
mysql dbnane<<EOFMYSQL
SELECT * from table;
EOFMYSQL
Go to the top of the page
 
+Quote Post
oracle765
post Apr 3 2014, 07:43 PM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 3
Joined: 8-January 14
Member No.: 18,617



Hi professionals I have an update

I now tried to run script.sh with the following command

#Get price retailers list
/usr/bin/wget -O "/home/oracle765/public_html/feed/getprice.txt" 'http://www.getprice.com.au/affinityclick/ShopsList.aspx?Pass=1iob2kjd&ref=cc';



mysql -u UNAME -p PASSWORD mysql.compareandchoose.com.au mydatabase -execute="LOAD DATA LOCAL INFILE '/home/oracle765/public_html/feed/getprice.txt' REPLACE INTO TABLE getpriceretailer FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' (id,name,url,logo,rank,products,List)"

mysql -u UNAME -p PASSWORD -h localhost mydatabase -e "LOAD DATA INFILE '/home/oracle765/public_html/feed/getprice.txt' REPLACE INTO TABLE getpriceretailer FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' (id,name,url,logo,rank,products,List)"




BOTH OF THESE WONT WORK AND PRODUCE THE ERROR MESSAGE BELOW


mysql Ver 14.14 Distrib 5.5.32, for Linux (x86_64) using readline 5.1 Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with
--disable-auto-rehash.
(Defaults to on; use --skip-auto-rehash to disable.)
-A, --no-auto-rehash
and so on

Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 12th December 2017 - 04:45 PM