[Gambas-user] import mysql dump EXEC or SHELL?

Doriano Blengino doriano.blengino at ...1909...
Tue Dec 16 20:50:23 CET 2008


Ron_1st ha scritto:
> On Tuesday 16 December 2008, wig wrote:
>   
>>  sImport = "< " & Application.Path & "/mytables.sql"
>>
>>  EXEC ["mysql", sUser, sPassword, sHost, sDatabase, sImport]
>>
>>     
>
>   sImport = "< "
>   sSqlFile = Application.Path & "/mytables.sql"
>
>   EXEC ["mysql", sUser, sPassword, sHost, sDatabase, sImport, sSqlFile ]
>
> Every item on the line for EXEC should be a seprate item in the array.
> The "<" is a seperate item/part of the line, it has space on both adjacent sides!
>   
No,

the "<" construct is a shell construct, not a linux/unix one. It is 
/bin/sh, or whatever, which interprets this notation and does a lot of 
job about it.
The gambas SHELL instruction calls /bin/sh, which is powerful 
(environment, PATH search, redirection and much more), so you can use 
all its features.

EXEC calls the unix system call execXX() (there are various) which are 
faster but not as powerful as /bin/sh.

I think the most notably differences are:
1. Using SHELL you specify the command to execute as you would do on the 
command line. ls is ls, and fdisk is fdisk. In EXEC, you *must* specify 
the correct path: /bin/ls, /sbin/fdisk... - Linux won't search the file 
for you. EXEC ["mysql", ...] can not work.

2. Again, parameters and constructs of SHELL are the same as those in 
the command line; you can use < > | and so on, and must quote words 
which contain spaces and other special chars. Using EXEC you don't have 
(well, you must not) quote parameters. and you don't have /bin/sh 
constructs.

Regards,

-- 
Doriano Blengino

"Listen twice before you speak.
This is why we have two ears, but only one mouth."





More information about the User mailing list