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,797
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

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: 23rd October 2017 - 12:16 PM