RE: executing c program from perl script and grabbing output
I have a c program which takes two commandline arguments (both strings) and prints out a line. If I use system then I am not able to grab the output of the program and if I use backquotes `` then the arguments are also treated as commands and I get an error. Is there any other way to do this. Ganapathy try - open(FL, |$cmd @args); while (FL){ print $_; } close (FL); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: executing c program from perl script and grabbing output
On Tuesday, July 2, 2002, at 11:23 , Shishir K. Singh wrote: I have a c program which takes two commandline arguments (both strings) and prints out a line. If I use system then I am not able to grab the output of the program and if I use backquotes `` then the arguments are also treated as commands and I get an error. Is there any other way to do this. Ganapathy try - open(FL, |$cmd @args); isn't that suppose to be open(FL, $cmd @args |); so that We can read the stdout of $cmd - vice writing stuff to it also isn't it safer to do the open(FL, $cmd @args 21 |) or die unable to deal with $cmd @args : $!\n; so that we get back all of the stdErr from $cmd, and expressly EXPLODE if there is some obvious reason that we can not execute $cmd ??? while (FL){ print $_; } close (FL); If you want to test stuff without actually having the command you can use uncle drieux's Handy Dandy DoCmd.txt spoofer - cf: http://www.wetware.com/drieux/pbl/perlTrick/drieuxTemplates/DoCmd.txt ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: executing c program from perl script and grabbing output
On Tuesday, July 2, 2002, at 11:23 , drieux wrote: I have a c program which takes two commandline arguments (both strings) and prints out a line. If I use system then I am not able to grab the output of the program and if I use backquotes `` then the arguments are also treated as commands and I get an error. Is there any other way to do this. Ganapathy try - open(FL, |$cmd @args); isn't that suppose to be open(FL, $cmd @args |); so that We can read the stdout of $cmd - vice writing stuff to it Damm those pipes...I always get confused between reading and writing!! You are correct!! also isn't it safer to do the open(FL, $cmd @args 21 |) or die unable to deal with $cmd @args : $!\n; so that we get back all of the stdErr from $cmd, and expressly EXPLODE if there is some obvious reason that we can not execute $cmd ??? while (FL){ print $_; } close (FL); This was just a test code. The validation and checks can be added by the programmer as desired. If you want to test stuff without actually having the command you can use uncle drieux's Handy Dandy DoCmd.txt spoofer - cf: http://www.wetware.com/drieux/pbl/perlTrick/drieuxTemplates/DoCmd.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]