LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-02-2004, 05:56 AM   #1
philipina
Member
 
Registered: May 2003
Posts: 77

Rep: Reputation: 15
Do not stop or exit from a script in case of error.


Hello,

I would like to execute a linux script including some mysql commands.
My problem is that my script is exiting in case of error.
Is there any possibility to automatically ignore in case of error and continue to execute all other mysql commands.

Thanks in advance.

Alain.
 
Old 07-02-2004, 06:10 AM   #2
wolfe2554
Member
 
Registered: Apr 2003
Location: denver co
Distribution: redhat9
Posts: 156

Rep: Reputation: 30
so when the program script in bash? right? is going though it exits because? well the only reason a script would exit is ctl c, return 1, or it is finished. can you give some more info pls.
thank you
wolfe
 
Old 07-02-2004, 06:30 AM   #3
philipina
Member
 
Registered: May 2003
Posts: 77

Original Poster
Rep: Reputation: 15
Yes, this is a bash file.

Example:

!#/bin/bash
exec mysql -e"INSERT INTO MyTable1 VALUES(1,2,3,4,5);"
exec mysql -e"INSERT INTO MyTable2 VALUES(1,2,3,4,5);"
exec mysql -e"INSERT INTO MyTable3 VALUES(1,2,3,4,5);"

If there is a problem in the first mysql command, all other mysql commands are not executed.

Thanks in advance.
 
Old 07-02-2004, 06:33 AM   #4
linuxxed
Member
 
Registered: Feb 2004
Posts: 273

Rep: Reputation: 30
Quote:
Originally posted by philipina
Yes, this is a bash file.

Example:

!#/bin/bash
exec mysql -e"INSERT INTO MyTable1 VALUES(1,2,3,4,5);"
exec mysql -e"INSERT INTO MyTable2 VALUES(1,2,3,4,5);"
exec mysql -e"INSERT INTO MyTable3 VALUES(1,2,3,4,5);"

If there is a problem in the first mysql command, all other mysql commands are not executed.

Thanks in advance.

remove the "exec". Exec causes the process to execute in the same shell.
!#/bin/bash
mysql -e"INSERT INTO MyTable1 VALUES(1,2,3,4,5);"
mysql -e"INSERT INTO MyTable2 VALUES(1,2,3,4,5);"
mysql -e"INSERT INTO MyTable3 VALUES(1,2,3,4,5);"
 
Old 07-02-2004, 06:52 AM   #5
philipina
Member
 
Registered: May 2003
Posts: 77

Original Poster
Rep: Reputation: 15
Yes, now it works fine!

Thanks you.

Alain.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
call another script and have the inital script exit mjtice Programming 1 09-11-2005 11:54 AM
change case of a string (TOUPPER) in shell script raees Linux - Software 3 05-03-2005 02:13 PM
i want to make a script with case.esac Alexander.s Linux - Newbie 3 12-14-2004 05:29 AM
Invoke script on xsession exit? comp12345 Linux - Software 1 06-27-2004 10:27 PM
script 'exit' command kilobravo Linux - General 8 01-16-2003 03:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12: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
Open Source Consulting | Domain Registration