Archive: Problem with spaces in nsExec


Problem with spaces in nsExec
Hi, I've read through all the posts/archives/examples/etc. but I can't seem to get my script working. I'm trying to do the following: the user presses a "Create Database" button and the installer runs mysql.exe, gives it a .sql file and builds the database.

My problem is that the default selection for the MySQL 4.3.10 installer are to a) not add the mysql.exe location to PATH and b) install MySQL to c:\program files\mysql\mysql server 4.1\

I can get this to work if the PATH is set, or if it's installed to somewhere without a space in the path (like c:\mysql) but if the above two conditions are both true then my script fails. Here is the relevant code:

nsExec::ExecToStack 'cmd /C "$mysql_path\mysql.exe" -uroot < "$PLUGINSDIR\create_lms_db.sql"'

where:
$mysql_path = C:\Program Files\MySQL\MySQL Server 4.1\bin

This returns:
'C:\Program' is not recognized as an internal command, operable program or batch file.

Other variations I've tried are:
ExecWait '"$mysql_path\mysql.exe" -uroot < "$PLUGINSDIR\create_lms_db.sql"'

nsExec::ExecToStack '"$mysql_path\mysql.exe" -uroot < "$PLUGINSDIR\create_lms_db.sql"'

For the above two, and basically all other variations, it seems like mysql.exe is getting called but it doesn't understand its input. The output of the mysql.exe command is what you get when you run "mysql.exe -?" (not any sort of file not found error -- like when running "mysql < asdf.asdf" -- or unknown option -- like when running "mysql -asdf").

Here's what I get:

C:\Program Files\mysql\MySQL Server 4.1\bin\mysql.exe Ver 14.7 Distrib 4.1.9, for Win95/Win98 (i32)
Copyright (C) 2002 MySQL 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: C:\Program Files\mysql\MySQL Server 4.1\bin\mysql.exe [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.
-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 r

Can anybody see what I'm doing wrong?

Thanks,
Chad Russell


Both nsExec and ExecDos can only create hidden process with redirected IO (pipes). Real console window also includes shell tricks ( < > ) and terminal emulation. This is why - mysql.exe not gets stdin from nsExec. Vbgunz also found problem with mysqladmin.exe - it looks like this program requires terminal emulation. But ExecWait with black console window should work I guess...
Another variant (with hidden window). If sql file size is less then 1k (or 8k for special NSIS build) you can read it to memory and use in the ExecDos as stdin. This explains how to read file to memory http://nsis.sourceforge.net/archive/...ances=0,11,814
ExecDos http://nsis.sourceforge.net/archive/...instances=0,32