Ron_1st ha scritto: > On Tuesday 16 December 2008, Doriano Blengino wrote: > >> 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. >> >> >> > When I do understand it correct the error in the line > >>> EXEC ["mysql", sUser, sPassword, sHost, sDatabase, sImport, sSqlFile ] >>> > is the missing path for "mysql" (?) > Pardon me. I got confused about the exec system call. I went to read the documentation, and made a simple test. EXEC finds the normal executables, in some way; so this is not the problem.
Your problem is that you can not do redirection using "<". It is the shell /bin/sh that does that; if you use such character in an EXEC statement, all you obtain is to pass the "<" character to the command you are invoking which, 99% of the times, will interpret it as a file name or part of it. You can do what you want do by this: dim sql_result as string SHELL "mysql -u user01 -p pwd01 ... < " & Application.Path &/ "mytables.sql" TO sql_result The "to sql_result" implies that the command is fully executed before returning, and you can analyze the string to look for errors and such. To use EXEC instead, you shoud do: EXEC ["/bin/sh", "-c", "mysql -u user01 -p pwd01 ... < " & Application.Path &/ "mytables.sql"] to sql_result (As you see, it simply calls /bin/sh passing it a command to execute. IE, this is the same as SHELL!) You can avoid to call "/bin/sh" if you don't need /bin/sh functionalities. Another, more controlled way, but more complicated, is to create the pipes yourself, and do what the shell would do. SHELL ... FOR INPUT OUTPUT ... This way, you can feed the command whatever you want, not just a file but live data you create on the fly, perhaps reading them from a file you opened... but this is another matter. Regards, -- Doriano Blengino "Listen twice before you speak. This is why we have two ears, but only one mouth." ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user