On 10/09/2002 20:56:39 perl-win32-users-admin wrote:
>I am having problems with a system call. I used perl2exe with a -gui >option, which means that no command prompt will pop up during execution and >the compiled script remains hidden. The problem is...Now that I did that, >my system call to an external exe no longer works. My system call is >currently set up in my script like this: > >$result = `$commandline`; # where $commandline is say, for example, >'blat.exe file.txt -body "body"' (this is just an example...the actual call >is MUCH longer) > Did you check the result ? unless( defined $result ) { # backticks return undef on failure die "command execution failed: $!, $^E" } >When using the -gui switch when compiling my perl script to an exe with >perl2exe, all STDIN and STDOUT is hidden, and for some reason this is >prohibiting my compiled perl script from running this system call. This is >BAD! I think this is a red herring at best. I don't know what perl2exe does, but I doubt it would prohibit running external programs. Run your script with 'wperl.exe' instead of 'perl.exe' and redirect both stdout and stderr: wperl script.pl 1>111 2>222 Do the same with the compiled program: script.exe 1>1111 2>2222 Check the content of the generated files. > >Unfortunately, I have to keep the compiled script 'hidden', so I need >another way to call this external program. > >I don't know how to do PIPES. This is the first time it's ever come up in >any of my programs. Using pipes is simple :-) open( PIPE, "$commandline |" ) or die "Could not open the pipe: $!, $^E"; # always check result of open while( <> ) { # process the output line-by-line } close( PIPE ) or die "close failed: $!, $^E" # always check result of close, especially if using pipes (see perlipc) > Is there a way to open a PIPEOUT to the external >program and get the result of the program from a PIPEIN? I need to store >the entire result of the external program to $result so that I can do some >error checking. That's not what you were doing. With backticks you can only read the output of the external program. With pipes you can choose whether to read or write. Check out the perlipc documentation. In principle, you cannot do both at the same time (but see the IPC::Open2 package, recommended in perlipc). > >This is very high priority, so if anyone has ANY ideas at all, helpful or >not, please feel free to respond! Thanks! > For every complicated problem there's an answer which is simple, neat, and wrong. :-) Disclaimer: I just typed these lines in, not tested them. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED] http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs