[Gambas-user] import mysql dump EXEC or SHELL?
Ron_1st
ronstk at ...239...
Wed Dec 17 13:09:52 CET 2008
On Wednesday 17 December 2008, Doriano Blengino wrote:
> Ron_1st ha scritto:
----8<----
> >>
> > 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.
OK
>
> 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.
Thanks for the lesson, now I understand the difference between
EXEC and SHELL a lot more.
>
> Regards,
>
> --
> Doriano Blengino
> "Listen twice before you speak.
> This is why we have two ears, but only one mouth."
Best regards
Ron_1st
--
A: Delete the text you reply on.
Q: What to do to get my post on top?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
P.S.
Just a side note.
At the moment when I 'reply' kmail strips every thing below the '--' as signature.
As result your name is also stripped (I did cut/paste to get it back here) and
also automagicly the advertisement from SF is gone away.
As in normal written mail the name of the writter is below the 'regards' and it
looks to me the '--' shouls below your name instead above.
More information about the User
mailing list