Re: Script question
Philippe Poelvoorde wrote: mysql system echo hi there; mysql system ls -ls; mysql system uname-a; all work on the 2.4.22-10mdk kernel and the semi-colon is optional. mysql system echo hi there should be also working, the first parameters 'echo' is recognized as the command to execute, and the folowings strings the parameters of this command. so since 'echo hi there' is not a command it wasn't working (try, doing `$echo\ hi\ there` at your prompt :) Since some commands require quotes, it could be useful. (system doesn't work with MySQL 3.23, does it ?) 4.0.18, doesnt seem to work 4 me. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Script question
Just so everyone is up to speed: The system client command is only available on Unix-like systems. To quote: http://dev.mysql.com/doc/mysql/en/mysql_Commands.html The edit, nopager, pager, and system commands work only in Unix. So depending on your OS, that command may or may not be available. Shawn Green Database Administrator Unimin Corporation - Spruce Pine Gerald Taylor [EMAIL PROTECTED] wrote on 10/20/2004 01:58:00 AM: Philippe Poelvoorde wrote: mysql system echo hi there; mysql system ls -ls; mysql system uname-a; all work on the 2.4.22-10mdk kernel and the semi-colon is optional. mysql system echo hi there should be also working, the first parameters 'echo' is recognized as the command to execute, and the folowings strings the parameters of this command. so since 'echo hi there' is not a command it wasn't working (try, doing `$echo\ hi\ there` at your prompt :) Since some commands require quotes, it could be useful. (system doesn't work with MySQL 3.23, does it ?) 4.0.18, doesnt seem to work 4 me. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Script question
mysql system echo hi there; mysql system ls -ls; mysql system uname-a; all work on the 2.4.22-10mdk kernel and the semi-colon is optional. mysql system echo hi there should be also working, the first parameters 'echo' is recognized as the command to execute, and the folowings strings the parameters of this command. so since 'echo hi there' is not a command it wasn't working (try, doing `$echo\ hi\ there` at your prompt :) Since some commands require quotes, it could be useful. (system doesn't work with MySQL 3.23, does it ?) -- Philippe Poelvoorde COS Trading Ltd. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Script question
Can anyone tell me how to make a scriptcontaining MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard#ASCII file.load data infile '/home/rhino/MySQL/SFL/FILMS.AS3'replace into table Dougs_Moviesfields terminated by ';'optionally enclosed by '"'escaped by '\\'lines starting by '"'terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo "Hello" or !echo "Hello" I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -umyid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that thetext of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino---rhino1 AT sympatico DOT ca"There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies." - C.A.R. Hoare
RE: Script question
Hi Rhino, This works, however I can't remember how to suppress the column heading. If you can do that, you can put anything you like in. [EMAIL PROTECTED] loganda]$ echo set @thing='here we go';select @thing| mysql -u root -p outfile Enter password: [EMAIL PROTECTED] loganda]$ cat outfile @thing here we go If you can work out how to suppress the column header please let me know Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that the text of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino --- rhino1 AT sympatico DOT ca There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare
RE: Script question
After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that the text of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino --- rhino1 AT sympatico DOT ca There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare
Re: Script question
Sorry, you still haven't got it;-) I want the echo command to be in the *script*, not to be supplied at the command line. Is there some way to put a mix of MySQL commands and OS commands into a script and have both executed successfully via: mysql -u myid -pmypass Load.sql Load.out Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:09 PM Subject: RE: Script question After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that the text of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino --- rhino1 AT sympatico DOT ca There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Script question
The only way to mix and match with an .sql script would be to use the system command. The example I showed below would echo the text required and that would be diverted to Load.out file eg. -- use SFL; system echo 'my choice of text'; system cat /etc/passwd; system cat afilethathasmytextinit; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; When run as mysql -u myid -pmypass Load.sql Load.out All output (including that of the system commands) will be echoed into the Load.out file Otherwise I'm confused as to what you are trying to do. Sorry 8-) Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax -Original Message- From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:53 AM To: Logan, David (SST - Adelaide); mysql Subject: Re: Script question Sorry, you still haven't got it;-) I want the echo command to be in the *script*, not to be supplied at the command line. Is there some way to put a mix of MySQL commands and OS commands into a script and have both executed successfully via: mysql -u myid -pmypass Load.sql Load.out Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:09 PM Subject: RE: Script question After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that the text of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino --- rhino1 AT sympatico DOT ca There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Script question
If you are on an *nix system you can try \! echo Hello test.txt Rhino wrote: Sorry, you still haven't got it;-) I want the echo command to be in the *script*, not to be supplied at the command line. Is there some way to put a mix of MySQL commands and OS commands into a script and have both executed successfully via: mysql -u myid -pmypass Load.sql Load.out Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:09 PM Subject: RE: Script question After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that the text of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino --- rhino1 AT sympatico DOT ca There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Script question
I thought you'd nailed it when I read your note but I found that your suggestion didn't work. When I tried executing the script with this added to it: system echo 'hi there'; I got this on the command line: sh: line 1: echo 'hi there': command not found I tried doing a man system and got an article from the Linux Programmer's Manual about a C function named system(). It's beginning to look like I don't have the 'system' command on my server. I am not a strong Unix person; should the 'system' command be there? I'm running Linux Mandrake 9.1. Maybe 'system' is only available on some of the Unix platforms but not Mandrake 9.1?? Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:31 PM Subject: RE: Script question The only way to mix and match with an .sql script would be to use the system command. The example I showed below would echo the text required and that would be diverted to Load.out file eg. -- use SFL; system echo 'my choice of text'; system cat /etc/passwd; system cat afilethathasmytextinit; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; When run as mysql -u myid -pmypass Load.sql Load.out All output (including that of the system commands) will be echoed into the Load.out file Otherwise I'm confused as to what you are trying to do. Sorry 8-) Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax -Original Message- From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:53 AM To: Logan, David (SST - Adelaide); mysql Subject: Re: Script question Sorry, you still haven't got it;-) I want the echo command to be in the *script*, not to be supplied at the command line. Is there some way to put a mix of MySQL commands and OS commands into a script and have both executed successfully via: mysql -u myid -pmypass Load.sql Load.out Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:09 PM Subject: RE: Script question After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that the text of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino --- rhino1 AT sympatico DOT ca There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Script question
try: system echo hi there; without the single quotes :) On Mon, 18 Oct 2004 21:04:19 -0400, Rhino [EMAIL PROTECTED] wrote: I thought you'd nailed it when I read your note but I found that your suggestion didn't work. When I tried executing the script with this added to it: system echo 'hi there'; I got this on the command line: sh: line 1: echo 'hi there': command not found I tried doing a man system and got an article from the Linux Programmer's Manual about a C function named system(). It's beginning to look like I don't have the 'system' command on my server. I am not a strong Unix person; should the 'system' command be there? I'm running Linux Mandrake 9.1. Maybe 'system' is only available on some of the Unix platforms but not Mandrake 9.1?? Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:31 PM Subject: RE: Script question The only way to mix and match with an .sql script would be to use the system command. The example I showed below would echo the text required and that would be diverted to Load.out file eg. -- use SFL; system echo 'my choice of text'; system cat /etc/passwd; system cat afilethathasmytextinit; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; When run as mysql -u myid -pmypass Load.sql Load.out All output (including that of the system commands) will be echoed into the Load.out file Otherwise I'm confused as to what you are trying to do. Sorry 8-) Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax -Original Message- From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:53 AM To: Logan, David (SST - Adelaide); mysql Subject: Re: Script question Sorry, you still haven't got it;-) I want the echo command to be in the *script*, not to be supplied at the command line. Is there some way to put a mix of MySQL commands and OS commands into a script and have both executed successfully via: mysql -u myid -pmypass Load.sql Load.out Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:09 PM Subject: RE: Script question After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that the text of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino --- rhino1 AT sympatico DOT ca There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe
Re: Script question
I got basically the same error: sh: line 1: echo Hi there: command not found I know that echo works; I can do: echo Hello or echo 'Hello' on the command line and the result is Hello. However, when I do this on a command line: system I get: -bash: system: command not found The problem seems to be that I don't have the system command on my Linux system. Is that normal for Mandrake 9.1? If it is, where do I get this command? I can get the system administrator to install the appropriate RPM if you can tell me what it is and where I can find it. Rhino - Original Message - From: Brian [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED] Cc: Logan, David (SST - Adelaide) [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 9:09 PM Subject: Re: Script question try: system echo hi there; without the single quotes :) On Mon, 18 Oct 2004 21:04:19 -0400, Rhino [EMAIL PROTECTED] wrote: I thought you'd nailed it when I read your note but I found that your suggestion didn't work. When I tried executing the script with this added to it: system echo 'hi there'; I got this on the command line: sh: line 1: echo 'hi there': command not found I tried doing a man system and got an article from the Linux Programmer's Manual about a C function named system(). It's beginning to look like I don't have the 'system' command on my server. I am not a strong Unix person; should the 'system' command be there? I'm running Linux Mandrake 9.1. Maybe 'system' is only available on some of the Unix platforms but not Mandrake 9.1?? Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:31 PM Subject: RE: Script question The only way to mix and match with an .sql script would be to use the system command. The example I showed below would echo the text required and that would be diverted to Load.out file eg. -- use SFL; system echo 'my choice of text'; system cat /etc/passwd; system cat afilethathasmytextinit; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; When run as mysql -u myid -pmypass Load.sql Load.out All output (including that of the system commands) will be echoed into the Load.out file Otherwise I'm confused as to what you are trying to do. Sorry 8-) Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax -Original Message- From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:53 AM To: Logan, David (SST - Adelaide); mysql Subject: Re: Script question Sorry, you still haven't got it;-) I want the echo command to be in the *script*, not to be supplied at the command line. Is there some way to put a mix of MySQL commands and OS commands into a script and have both executed successfully via: mysql -u myid -pmypass Load.sql Load.out Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:09 PM Subject: RE: Script question After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out
RE: Script question
Brian mailto:[EMAIL PROTECTED] wrote: try: system echo hi there; without the single quotes :) On Mon, 18 Oct 2004 21:04:19 -0400, Rhino [EMAIL PROTECTED] wrote: I thought you'd nailed it when I read your note but I found that your suggestion didn't work. When I tried executing the script with this added to it: system echo 'hi there'; I got this on the command line: sh: line 1: echo 'hi there': command not found I tried doing a man system and got an article from the Linux Programmer's Manual about a C function named system(). It's beginning to look like I don't have the 'system' command on my server. I am not a strong Unix person; should the 'system' command be there? I'm running Linux Mandrake 9.1. Maybe 'system' is only available on some of the Unix platforms but not Mandrake 9.1?? Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:31 PM Subject: RE: Script question The only way to mix and match with an .sql script would be to use the system command. The example I showed below would echo the text required and that would be diverted to Load.out file eg. -- use SFL; system echo 'my choice of text'; system cat /etc/passwd; system cat afilethathasmytextinit; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; When run as mysql -u myid -pmypass Load.sql Load.out All output (including that of the system commands) will be echoed into the Load.out file Otherwise I'm confused as to what you are trying to do. Sorry 8-) Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax -Original Message- From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:53 AM To: Logan, David (SST - Adelaide); mysql Subject: Re: Script question Sorry, you still haven't got it;-) I want the echo command to be in the *script*, not to be supplied at the command line. Is there some way to put a mix of MySQL commands and OS commands into a script and have both executed successfully via: mysql -u myid -pmypass Load.sql Load.out Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:09 PM Subject: RE: Script question After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that the text of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino --- rhino1 AT sympatico DOT ca There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] No quotes at all mysql system echo hi
Re: Script question
No, the system command is part of the mysql interpreter, do a \h and see if it's listed, if it isn't then there is only one other way to do it. Split your sql script up into several pieces and have a shell script call it like this: mysql script1.sql echo here's some output mysql script2.sql echo here's some more output etc... On Mon, 18 Oct 2004 21:19:13 -0400, Rhino [EMAIL PROTECTED] wrote: I got basically the same error: sh: line 1: echo Hi there: command not found I know that echo works; I can do: echo Hello or echo 'Hello' on the command line and the result is Hello. However, when I do this on a command line: system I get: -bash: system: command not found The problem seems to be that I don't have the system command on my Linux system. Is that normal for Mandrake 9.1? If it is, where do I get this command? I can get the system administrator to install the appropriate RPM if you can tell me what it is and where I can find it. Rhino - Original Message - From: Brian [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED] Cc: Logan, David (SST - Adelaide) [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 9:09 PM Subject: Re: Script question try: system echo hi there; without the single quotes :) On Mon, 18 Oct 2004 21:04:19 -0400, Rhino [EMAIL PROTECTED] wrote: I thought you'd nailed it when I read your note but I found that your suggestion didn't work. When I tried executing the script with this added to it: system echo 'hi there'; I got this on the command line: sh: line 1: echo 'hi there': command not found I tried doing a man system and got an article from the Linux Programmer's Manual about a C function named system(). It's beginning to look like I don't have the 'system' command on my server. I am not a strong Unix person; should the 'system' command be there? I'm running Linux Mandrake 9.1. Maybe 'system' is only available on some of the Unix platforms but not Mandrake 9.1?? Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:31 PM Subject: RE: Script question The only way to mix and match with an .sql script would be to use the system command. The example I showed below would echo the text required and that would be diverted to Load.out file eg. -- use SFL; system echo 'my choice of text'; system cat /etc/passwd; system cat afilethathasmytextinit; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; When run as mysql -u myid -pmypass Load.sql Load.out All output (including that of the system commands) will be echoed into the Load.out file Otherwise I'm confused as to what you are trying to do. Sorry 8-) Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax -Original Message- From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:53 AM To: Logan, David (SST - Adelaide); mysql Subject: Re: Script question Sorry, you still haven't got it;-) I want the echo command to be in the *script*, not to be supplied at the command line. Is there some way to put a mix of MySQL commands and OS commands into a script and have both executed successfully via: mysql -u myid -pmypass Load.sql Load.out Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:09 PM Subject: RE: Script question After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file
Re: Script question
Thanks, Charles! Your suggestion about removing the quotes and apostrophes altogether did the trick! Rhino - Original Message - From: Sweet, Charles E [EMAIL PROTECTED] To: mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 9:22 PM Subject: RE: Script question Brian mailto:[EMAIL PROTECTED] wrote: try: system echo hi there; without the single quotes :) On Mon, 18 Oct 2004 21:04:19 -0400, Rhino [EMAIL PROTECTED] wrote: I thought you'd nailed it when I read your note but I found that your suggestion didn't work. When I tried executing the script with this added to it: system echo 'hi there'; I got this on the command line: sh: line 1: echo 'hi there': command not found I tried doing a man system and got an article from the Linux Programmer's Manual about a C function named system(). It's beginning to look like I don't have the 'system' command on my server. I am not a strong Unix person; should the 'system' command be there? I'm running Linux Mandrake 9.1. Maybe 'system' is only available on some of the Unix platforms but not Mandrake 9.1?? Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:31 PM Subject: RE: Script question The only way to mix and match with an .sql script would be to use the system command. The example I showed below would echo the text required and that would be diverted to Load.out file eg. -- use SFL; system echo 'my choice of text'; system cat /etc/passwd; system cat afilethathasmytextinit; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; When run as mysql -u myid -pmypass Load.sql Load.out All output (including that of the system commands) will be echoed into the Load.out file Otherwise I'm confused as to what you are trying to do. Sorry 8-) Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax -Original Message- From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:53 AM To: Logan, David (SST - Adelaide); mysql Subject: Re: Script question Sorry, you still haven't got it;-) I want the echo command to be in the *script*, not to be supplied at the command line. Is there some way to put a mix of MySQL commands and OS commands into a script and have both executed successfully via: mysql -u myid -pmypass Load.sql Load.out Rhino - Original Message - From: Logan, David (SST - Adelaide) [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED]; mysql [EMAIL PROTECTED] Sent: Monday, October 18, 2004 8:09 PM Subject: RE: Script question After re-reading your email in not so quite a rush 8-) Further to that, you can use the system command to run an OS command eg. system echo thing; mysql system echo thing; thing mysql Regards David Logan Database Administrator HP Managed Services 148 Frome Street, Adelaide 5000 Australia +61 8 8408 4273 - Work +61 417 268 665 - Mobile +61 8 8408 4259 - Fax From: Rhino [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 October 2004 9:13 AM To: mysql Subject: Script question Can anyone tell me how to make a script containing MySQL commands also execute an OS command? For instance, given this script, called Load.sql: -- use SFL; #Load the data from the export file that was exported from QA as a standard #ASCII file. load data infile '/home/rhino/MySQL/SFL/FILMS.AS3' replace into table Dougs_Movies fields terminated by ';' optionally enclosed by '' escaped by '\\' lines starting by '' terminated by '\r\n'; I'd like to add some 'echo' statements to the script. However, when I include: echo Hello or !echo Hello I get a syntax error when I execute the script. I am executing the script from the Linux command line via this command: mysql -u myid -pmypass Load.sql Load.out It isn't strictly necessary to include 'echo' commands in the script as long as I can ensure that the text of my choice appears in the Load.out file in the place of my choosing, i.e. after the 'use' command has been executed but before the 'load' command has been executed. Can anyone help me this problem? I can't believe it is hard but I can't think what to search on in the archives. Rhino --- rhino1 AT sympatico DOT ca There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious