Fix to buf 553 http://bugs.mariadb.com/show_bug.cgi?id=553
Added command line argument for '-f <filename>' that executes the commands found in the file.
This commit is contained in:
@ -55,6 +55,8 @@
|
|||||||
#include <histedit.h>
|
#include <histedit.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BUFFSIZE 2048
|
||||||
|
|
||||||
static int connectMaxScale(char *hostname, char *port);
|
static int connectMaxScale(char *hostname, char *port);
|
||||||
static int setipaddress(struct in_addr *a, char *p);
|
static int setipaddress(struct in_addr *a, char *p);
|
||||||
static int authMaxScale(int so, char *user, char *password);
|
static int authMaxScale(int so, char *user, char *password);
|
||||||
@ -111,12 +113,16 @@ char *passwd = NULL;
|
|||||||
int so;
|
int so;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
char c;
|
char c;
|
||||||
|
FILE* localfile = NULL;
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "h:p:P:u:v?",
|
while ((c = getopt_long(argc, argv, "f:h:p:P:u:v?",
|
||||||
long_options, &option_index))
|
long_options, &option_index))
|
||||||
>= 0)
|
>= 0)
|
||||||
{
|
{
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'f':
|
||||||
|
localfile = fopen(optarg,"r");
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
hostname = strdup(optarg);
|
hostname = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
@ -175,7 +181,19 @@ char c;
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc) {
|
if(localfile){
|
||||||
|
char buffer[BUFFSIZE];
|
||||||
|
|
||||||
|
fgets(buffer,BUFFSIZE,localfile);
|
||||||
|
|
||||||
|
while(!feof(localfile)){
|
||||||
|
sendCommand(so, buffer);
|
||||||
|
fgets(buffer,BUFFSIZE,localfile);
|
||||||
|
}
|
||||||
|
fclose(localfile);
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
}else if (optind < argc) {
|
||||||
int i, len = 0;
|
int i, len = 0;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user