Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Shellexecute (https://www.delphipraxis.net/6929-shellexecute.html)

Andreas L. 27. Jul 2003 18:32


Shellexecute
 
Hi,
ich ahbe da ein Problem. Ich möchte ein MySQL Tool progarmmieren. Damit man eine datenbank erstellen kann, ruft man normalerweise das proggi mysql.exe über die command line auf. Und gibt ein
Code:
create database TEST;
.
Ich rufe diese MySQl.exe mit Shellexecute auf. Nun möchte ich das
Code:
create database TEST;
nach der Ausführung des Porggis dort ausgeführt wird. Es soll den gleichen Effekt haben wie als wenn ich den oben erlauterten Schritt mache. Mit Parameter wie z.B. -create oder ähnlcihen ging e snicht. Wie stelel ich das an. Bin wirklich ratlos.

thx

Chewie 27. Jul 2003 18:40

Re: Shellexecute
 
Verstehe ich dich richtig, du willst MySQL-Querys an den Server über das Konsolen-Client-Tool mysql schicken? Das würde ich nicht empfehlen, da gibt es bessere Lösungen.
Such mal hier Forum:
Hier im Forum suchenmysql pas
Hier im Forum suchenzeos
Zu ersterem gibts hier auch ein Tutorial, allerdings bsiher nur der erste Teil (Verdammt, ich müsste mal den zweiten Teil fertigmachen :oops: )

Alexander 27. Jul 2003 18:40

Re: Shellexecute
 
Kuck dir mal Chewies Tutorial dazu an:
http://www.delphipraxis.net/viewtopic.php?t=7266
[edit]mist zu spät[/edit]

Andreas L. 27. Jul 2003 18:44

Re: Shellexecute
 
Das Tool soll nur für den lokalen MySQL Server sein. Geht das nicht irgendwie mit ShellExecute?

Alexander 27. Jul 2003 18:48

Re: Shellexecute
 
Mit der mysql.pas funktioniert, dass doch genauso gut, nur besser ;-)
Denn dein Programm ist eigenständiger...
Über Shellexecute ist das doch viel zu umständlich...

Luckie 27. Jul 2003 18:52

Re: Shellexecute
 
Kuck dir mal an welcher Parameter bei Shellexecute die Parameter enthält.

Chewie 27. Jul 2003 19:19

Re: Shellexecute
 
Ich weiß gar nicht, ob mysql Parameter entgegennehmen kann (oder besser gesagt verarbeiten). Die Eingabe der Query erfolgt ja so wie bei Microsofts Konsolen-FTP-Client (ich weiß nicht, wie man dieses Verfahren nennt).

Phoenix 27. Jul 2003 19:45

Re: Shellexecute
 
Um es kurz zu machen: Über ShellExecute geht es nicht.

Das Tool mysql.exe stellt selber eine persistente Verbindung zur Datenbank her (ähnlich wie Telnet, es ist also eine offene Session), über die dann die Abfragen und Antworten der Datenbank laufen.

Shellexecute ruft demnach nur das Tool auf, das die Verbindung herstellt. Du kannst aber hinterher nicht mehr darauf zugreifen und Abfragen an die Datenbank schicken lassen. Zumindest nicht ohne weiteres. Wenn ein command-window aufgeht könntest Du natürlich dessen Handle herausfinden und die einzugebenden Tasten nacheinander da hin schicken, aber das wäre etwas arg umständlich, zumal Du die Antwort da nicht mehr so ohne weiteres herausbekommen kannst.

Die einfachste Version ist also tatsächlich eine eigene persisente Verbindung aufzumachen und damit zu arbeiten.

Andreas L. 27. Jul 2003 19:53

Re: Shellexecute
 
Danke für eure Antworten. Werde mir später das Tut von Chewie mal anschauen.

Gast 27. Jul 2003 21:13

Re: Shellexecute
 
Soweit ich mich entsinne, sind TELNET und FTP von MS skriptfähig. Will heißen, wenn du eine Textdatei hineinpipst, könnte es auch mit MySQL gehen. Könnte! ... keine Garantie.

Andreas L. 28. Jul 2003 07:55

Re: Shellexecute
 
Zitat:

Zitat von dReM2nUtD3yZYpRco7D6ZOA
Soweit ich mich entsinne, sind TELNET und FTP von MS skriptfähig. Will heißen, wenn du eine Textdatei hineinpipst, könnte es auch mit MySQL gehen. Könnte! ... keine Garantie.

Oder evtl. Mit einer Batchdatei die während der Laufzeit erstellt wird und nach ausführen wieder gelöscht wird??? Könnte das gehen?

Chewie 28. Jul 2003 10:38

Re: Shellexecute
 
Ich kenn mich mit Named Pipes nicht aus, aber mysql kann den Parameter --pipe entgegennehmenn und nutzt dann Named Pipes. Vielleicht kannst du damit was anfangen.
Alle Parameter:

Zitat:


mysql Ver 11.18 Distrib 3.23.54, for Win95/Win98 (i32)
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Usage: mysql [OPTIONS] [database]

-?, --help Display this help and exit.
-A, --no-auto-rehash No automatic rehashing. One has to use 'rehash' to
get table and field completion. This gives a quicker
start of mysql and disables rehashing on reconnect.
-B, --batch Print results with a tab as separator, each row on
a new line. Doesn't use history file.
--character-sets-dir=...
Directory where character sets are located.
-C, --compress Use compression in server/client protocol.
-D, --database=.. Database to use.
--default-character-set=...
Set the default character set.
-e, --execute=... Execute command and quit. (Output like with --batch)
-E, --vertical Print the output of a query (rows) vertically.
-f, --force Continue even if we get an sql error.
-g, --no-named-commands
Named commands are disabled. Use \* form only, or
use named commands only in the beginning of a line
ending with a semicolon (;) Since version 10.9 the
client now starts with this option ENABLED by
default! Disable with '-G'. Long format commands
still work from the first line.
-G, --enable-named-commands
Named commands are enabled. Opposite to -g.
-i, --ignore-spaces Ignore spaces after function names.
-h, --host=... Connect to host.
-H, --html Produce HTML output.
--local-infile=[1|0] Enable/disable LOAD DATA LOCAL INFILE
-L, --skip-line-numbers
Don't write line number for errors.
--no-tee Disable outfile. See interactive help (\h) also.
-n, --unbuffered Flush buffer after each query.
-N, --skip-column-names
Don't write column names in results.
-O, --set-variable var=option
Give a variable an value. --help lists variables.
-o, --one-database Only update the default database. This is useful
for skipping updates to other database in the update
log.
-p[password], --password[=...]
Password to use when connecting to server
If password is not given it's asked from the tty.
-W, --pipe Use named pipes to connect to server

-P, --port=... Port number to use for connection.
-q, --quick Don't cache result, print it row by row. This may
slow down the server if the output is suspended.
Doesn't use history file.
-r, --raw Write fields without conversion. Used with --batch
-s, --silent Be more silent.
-S --socket=... Socket file to use for connection.
-t, --table Output in table format.
-T, --debug-info Print some debug info at exit.
--tee=... Append everything into outfile. See interactive help
(\h) also. Does not work in batch mode.
-u, --user=# User for login if not current user.
-U, --safe-updates[=#], --i-am-a-dummy[=#]
Only allow UPDATE and DELETE that uses keys.
-v, --verbose Write more. (-v -v -v gives the table output format)
-V, --version Output version information and exit.
-w, --wait Wait and retry if connection is down.

Default options are read from the following files in the given order:
D:\WINNT\my.ini C:\my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read

Possible variables for option --set-variable (-O) are:
connect_timeout current value: 0
max_allowed_packet current value: 16777216
net_buffer_length current value: 16384
select_limit current value: 1000
max_join_size current value: 1000000

Andreas L. 28. Jul 2003 11:14

Re: Shellexecute
 
Zitat:

Zitat von Chewie
Ich kenn mich mit Named Pipes nicht aus, aber mysql kann den Parameter --pipe entgegennehmenn und nutzt dann Named Pipes. Vielleicht kannst du damit was anfangen.
Alle Parameter:

Zitat:


mysql Ver 11.18 Distrib 3.23.54, for Win95/Win98 (i32)
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Usage: mysql [OPTIONS] [database]

-?, --help Display this help and exit.
-A, --no-auto-rehash No automatic rehashing. One has to use 'rehash' to
get table and field completion. This gives a quicker
start of mysql and disables rehashing on reconnect.
-B, --batch Print results with a tab as separator, each row on
a new line. Doesn't use history file.
--character-sets-dir=...
Directory where character sets are located.
-C, --compress Use compression in server/client protocol.
-D, --database=.. Database to use.
--default-character-set=...
Set the default character set.
-e, --execute=... Execute command and quit. (Output like with --batch)
-E, --vertical Print the output of a query (rows) vertically.
-f, --force Continue even if we get an sql error.
-g, --no-named-commands
Named commands are disabled. Use \* form only, or
use named commands only in the beginning of a line
ending with a semicolon (;) Since version 10.9 the
client now starts with this option ENABLED by
default! Disable with '-G'. Long format commands
still work from the first line.
-G, --enable-named-commands
Named commands are enabled. Opposite to -g.
-i, --ignore-spaces Ignore spaces after function names.
-h, --host=... Connect to host.
-H, --html Produce HTML output.
--local-infile=[1|0] Enable/disable LOAD DATA LOCAL INFILE
-L, --skip-line-numbers
Don't write line number for errors.
--no-tee Disable outfile. See interactive help (\h) also.
-n, --unbuffered Flush buffer after each query.
-N, --skip-column-names
Don't write column names in results.
-O, --set-variable var=option
Give a variable an value. --help lists variables.
-o, --one-database Only update the default database. This is useful
for skipping updates to other database in the update
log.
-p[password], --password[=...]
Password to use when connecting to server
If password is not given it's asked from the tty.
-W, --pipe Use named pipes to connect to server

-P, --port=... Port number to use for connection.
-q, --quick Don't cache result, print it row by row. This may
slow down the server if the output is suspended.
Doesn't use history file.
-r, --raw Write fields without conversion. Used with --batch
-s, --silent Be more silent.
-S --socket=... Socket file to use for connection.
-t, --table Output in table format.
-T, --debug-info Print some debug info at exit.
--tee=... Append everything into outfile. See interactive help
(\h) also. Does not work in batch mode.
-u, --user=# User for login if not current user.
-U, --safe-updates[=#], --i-am-a-dummy[=#]
Only allow UPDATE and DELETE that uses keys.
-v, --verbose Write more. (-v -v -v gives the table output format)
-V, --version Output version information and exit.
-w, --wait Wait and retry if connection is down.

Default options are read from the following files in the given order:
D:\WINNT\my.ini C:\my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read

Possible variables for option --set-variable (-O) are:
connect_timeout current value: 0
max_allowed_packet current value: 16777216
net_buffer_length current value: 16384
select_limit current value: 1000
max_join_size current value: 1000000

Das weiß ich auch schon, mein problem ist. Das ich irgendwie mein proggi dazu bringen muss wenn du mysql.exe gestartet wurde dann create database (edit1.text) zu übergeben.

Chewie 28. Jul 2003 11:32

Re: Shellexecute
 
Ja, das geht vielleicht über Named Pipes.
Schau dir dazu mal den Bereich im PSDK oder bei MSDN an.


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:56 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz