
this will be EASY for you to fix, I am sure... what the heck am I doing wrong: import System.Environment(getArgs)import System.Process(readProcessWithExitCode)import System.Exit(exitWith) main = do args <- getArgs (ecode,out,err) <- readProcessWithExitCode "c:\\Perl64\\bin\\perl.exe" ("C:\\Program Files\\MySQL\\scripts\\mysql_config.pl" : args) "" if ecode == System.Exit.ExitCode.ExitSuccess then return out else return err exitWith ecode

This compiles:
import System.Environment(getArgs)
import System.Process(readProcessWithExitCode)
import System.Exit(exitWith,ExitCode(ExitSuccess))
main = do
args <- getArgs
(ecode,out,err) <- readProcessWithExitCode
"c:\\Perl64\\bin\\perl.exe" ("C:\\Program
Files\\MySQL\\scripts\\mysql_config.pl" : args) ""
if ecode == ExitSuccess
then return out
else return err
exitWith ecode
I had trouble with the spacing you had when I pasted your code, and
also changed the imports so that ExitSuccess was being imported.
All the best,
Nick
On Thu, Mar 18, 2010 at 6:46 PM, Roderick Ford
this will be EASY for you to fix, I am sure... what the heck am I doing wrong: import System.Environment(getArgs) import System.Process(readProcessWithExitCode) import System.Exit(exitWith) main = do args <- getArgs (ecode,out,err) <- readProcessWithExitCode "c:\\Perl64\\bin\\perl.exe" ("C:\\Program Files\\MySQL\\scripts\\mysql_config.pl" : args) "" if ecode == System.Exit.ExitCode.ExitSuccess then return out else return err exitWith ecode
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Yes, THANKS!! But my other problem was, that once I get it to compile, I get nothing output: C:\Program Files\MySQL\bin>ghc --make -o mysql_config.exe main.hs[1 of 1] Compiling Main ( main.hs, main.o )Linking mysql_config.exe ... C:\Program Files\MySQL\bin>mysql_config --libs C:\Program Files\MySQL\bin>mysql_config --goob C:\Program Files\MySQL\bin>pwhich mysql_config.\mysql_config.EXE ... yet instead, I should be getting this: C:\Program Files\MySQL\bin>..\scripts\mysql_config.pl --libs"C:\Program Files\MySQL/lib/mysqlclient.lib" "wsock32.lib" "advapi32.lib" "user32.lib" C:\Program Files\MySQL\bin>..\scripts\mysql_config.pl --goobUnknown option: goobUsage: C:\Program Files\MySQL\scripts\mysql_config.pl [OPTIONS]Options: --cflags ["-IC:\Program Files\MySQL/include/mysql" "-D_WINDOWS""/MT" "/Zi" "/O2" "/Ob1" "/D" "NDEBUG" "-DDBUG_OFF" "/wd4996"] --include ["-IC:\Program Files\MySQL/include/mysql"] --libs ["C:\Program Files\MySQL/lib/mysqlclient.lib" "wsock32.lib" "advapi32.lib" "user32.lib"] --libs_r ["C:\Program Files\MySQL/lib/mysqlclient.lib" "wsock32.lib" "advapi32.lib" "user32.lib"] --socket [/tmp/mysql.sock] --port [0] --version [5.1.45] --libmysqld-libs ["C:\Program Files\MySQL/lib/mysqlserver.lib" "wsock32.lib" "advapi32.lib" "user32.lib"] ... so, it looks like I am handling the IO wrong, or else I go directly to the exitWith instead of returning the IO from "return". So, I suppose this is normal behavior, but how do you do BOTH. I guess I should actually be "print"ing the output rather than returning it, then doing the exitWith.
Date: Thu, 18 Mar 2010 18:56:12 +0000 Subject: Re: [Haskell-cafe] little help please From: nicolas.wu@gmail.com To: developer@live.com CC: haskell-cafe@haskell.org
This compiles:
import System.Environment(getArgs) import System.Process(readProcessWithExitCode) import System.Exit(exitWith,ExitCode(ExitSuccess))
main = do args <- getArgs (ecode,out,err) <- readProcessWithExitCode "c:\\Perl64\\bin\\perl.exe" ("C:\\Program Files\\MySQL\\scripts\\mysql_config.pl" : args) "" if ecode == ExitSuccess then return out else return err exitWith ecode
I had trouble with the spacing you had when I pasted your code, and also changed the imports so that ExitSuccess was being imported.
All the best,
Nick
On Thu, Mar 18, 2010 at 6:46 PM, Roderick Ford
wrote: this will be EASY for you to fix, I am sure... what the heck am I doing wrong: import System.Environment(getArgs) import System.Process(readProcessWithExitCode) import System.Exit(exitWith) main = do args <- getArgs (ecode,out,err) <- readProcessWithExitCode "c:\\Perl64\\bin\\perl.exe" ("C:\\Program Files\\MySQL\\scripts\\mysql_config.pl" : args) "" if ecode == System.Exit.ExitCode.ExitSuccess then return out else return err exitWith ecode
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Mar 18, 2010, at 15:14 , Roderick Ford wrote:
... so, it looks like I am handling the IO wrong, or else I go directly to the exitWith instead of returning the IO from "return". So, I suppose this is normal behavior, but how do you do BOTH. I guess I should actually be "print"ing the output rather than returning it, then doing the exitWith.
The problem is you're not doing anything with the thing you're returning; if you turn on warnings you should get something about discarding an (IO String) which is the result of your "if" expression. Normal behavior would be to send successful output to stdout and error output to stderr, so you would replace the first (return out) with (putStrLn out) and the second with (hPutStrLn stderr err); for the latter you'll also need to import stderr from System.IO. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (3)
-
Brandon S. Allbery KF8NH
-
Nicolas Wu
-
Roderick Ford