LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-27-2005, 10:12 AM   #1
petenyce
Member
 
Registered: Sep 2005
Posts: 39

Rep: Reputation: 15
Linux Script problem


I created this script in windows and transferred it to linux. Now this script gives me a error. It says no such file or directory in /usr/etc/scripts/script.sql But i have my file in that directory? is it a bracket missing? please check my script dont know where the error is

thanks



/usr/bin/mysql -h localhost -u root ehpadmin < /usr/etc/scripts/script.sql
/usr/bin/mysqldump -h localhost -u root ehpadmin > backup.txt
/usr/bin/mysqldump -h localhost -u root --tab=/usr/etc/scripts/ --fields-terminated-by=";" --lines-terminated-by="\n" --no-create-info ehpadmin Direct_Referral
/usr/bin/mysqldump -h localhost -u root --tab=/usr/etc/scripts/ --fields-terminated-by=";" --lines-terminated-by="\n" --no-create-info ehpadmin Referral_Authorization
/usr/bin/mysql -h localhost -u root ehpadmin < /usr/etc/scripts/truncate.sql
 
Old 09-27-2005, 12:02 PM   #2
john2
Member
 
Registered: Aug 2004
Location: Wales
Distribution: Mint, Mageia, OpenSUSE, Kubuntu
Posts: 95

Rep: Reputation: 25
This is probably caused by Windows line throw characters. Take a backup copy of your script (just in case) and convert them with
Code:
dos2unix myscript.sh
where myscript.sh is your script.

Last edited by john2; 09-27-2005 at 12:04 PM.
 
Old 09-27-2005, 12:16 PM   #3
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,751

Rep: Reputation: 272Reputation: 272Reputation: 272
You also need some continuations. A line is continued by a backslash just ahead of the return.

/usr/bin/mysql -h localhost -u root ehpadmin < /usr/etc/scripts/script.sql
/usr/bin/mysqldump -h localhost -u root ehpadmin > backup.txt
/usr/bin/mysqldump -h localhost -u root --tab=/usr/etc/scripts/ --fields-terminated-by=";" \ --lines-terminated-by="\n" --no-create-info ehpadmin Direct_Referral
/usr/bin/mysqldump -h localhost -u root --tab=/usr/etc/scripts/ --fields-terminated-by=";" \ --lines-terminated-by="\n" --no-create-info ehpadmin Referral_Authorization
/usr/bin/mysql -h localhost -u root ehpadmin < /usr/etc/scripts/truncate.sql

-----------------------------
Steve Stites
 
Old 09-27-2005, 01:28 PM   #4
petenyce
Member
 
Registered: Sep 2005
Posts: 39

Original Poster
Rep: Reputation: 15
ok well

i simply just tried to run a more simplier script and it dosent do anything. im new to linux. I click the .bat and run it form the command terminal and nothing happens. The data should move from my Referral_Authorization table to my referralhistory table?????
If i am missing soemthing please let me know

thanks do i ahev to re write this a different way???

.bat file
/usr/bin/mysql -h localhost -u root ehpadmin < /usr/etc/scripts/script.sql

script.sql
INSERT INTO referralhistory(MEMBERID)
select MEMBERID from FROM Referral_Authorization WHERE FORMTYPE ="D";
 
Old 09-28-2005, 04:17 AM   #5
john2
Member
 
Registered: Aug 2004
Location: Wales
Distribution: Mint, Mageia, OpenSUSE, Kubuntu
Posts: 95

Rep: Reputation: 25
1) I'm not an expert in MySQL, but in Oracle SQL, single (not double) quotes are used around string literals.
2) You have repeated the word FROM.

So the last statement should be:
Code:
INSERT INTO referralhistory(MEMBERID)
select MEMBERID FROM Referral_Authorization WHERE FORMTYPE = 'D';
It is best to try SQL statements from the command line before putting them into a batch file. That way you can debug them.

Last edited by john2; 09-28-2005 at 06:55 AM.
 
Old 09-28-2005, 10:29 AM   #6
petenyce
Member
 
Registered: Sep 2005
Posts: 39

Original Poster
Rep: Reputation: 15
almost their

I got half the script to work. now i have a piece of script that writes my record from my mysql tbale into a csv file. the code below works in windows. how can i get it to work in linux.


/usr/bin/mysqldump -h localhost -u root --tab=/usr/etc/scripts --fields-terminated-by=";" --lines-terminated-by="\n" --no-create-info ehpadmin referral_authorization


Now am i missing soemthing (brackets etc)becuase this part of my script is suppose to write a csv file???


please help thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
Problem executing a linux script from php that runs ffmpeg darkisolde Linux - Software 4 10-04-2005 08:43 AM
PPPD Script problem when cron-scheduling the script andresurzagasti Linux - Networking 0 11-24-2004 03:54 PM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 11:22 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 05:21 PM


All times are GMT -5. The time now is 01:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration