08-17-2012 01:17 PM
I'm trying to dynamically create a MySQL database from an SQL script file, when I call the System Exec VI I get the above error
my command input looks like this:
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe"
my standard input input looks like this:
"--defaults-file=C:\ProgramData\MySQL\MySQL Server 5.5\my.ini" " -uroot" "-ppassword" < "C:\Users\doug.wood\AppData\Local\Temp\PowerCycle_Results_8_16_12_9_49_56_AM.sql"
if I paste the whole command in a CMD window it works fine, my db is created (all quotes are included)
if I try passing the whole thing on just the command input mysql just displays the help info - no errors.
anyone have any idea of how I can get this to work?, oh I'm using LabVIEW 2011 SP1
TIA
Solved! Go to Solution.
08-20-2012 12:01 PM
Hi DogOnWood,
LabVIEW will insert escape characters by default into string constants. This may be modifying your string an an expected way when it goes out to the command prompt. Try right-clicking the string constants that you are inputting to the System Exec VI and turn on the '\' Codes Display option in the context menu. Look carefully at how the escape codes are being used to ensure the correct string is being sent to the command prompt.
When using options following a call to an exe, a common method that works for people is to create a batch file with the file name and options specified inside it. You may then call the batch file directly from the System Exec VI. This is outlined in the System Exec VI help file:
"To launch an executable with options using the syntax filename.exe -option1 -option2, create a filename.bat file that calls the executable with the options syntax and use this VI to call the filename.bat file."
In this case, you can programmatically create a batch file using the Write to Text File VI first with your commands, and then use System Exec to run the file:
Write to Text File Help - http://zone.ni.com/reference/en-XX/help/371361H-01/glang/write_characters_to_file/
Ideally, we recommend using LabVIEW's Database Connectivity toolkit for connecting to databases, as it takes care of much of this for you. You can find more information on that here:
Database Connectivity Toolkit - http://sine.ni.com/nips/cds/view/p/lang/en/nid/209060
Regards,