[PHP] EOF: how to generate one in a string
I am trying to use a command line program in Linux using this form: $result = `/path/prog $arg`; But this doesn't work as the program is expecting and EOF that never comes. If I use the program on the command line when I am finished entering all the data I need to hit return and then CTRL-D to give an EOF. How can I simulate this using the backticks? Thanks! Jc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] EOF: how to generate one in a string
- Original Message - From: Jean-Christian Imbeault [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 08, 2003 9:52 AM Subject: [PHP] EOF: how to generate one in a string I am trying to use a command line program in Linux using this form: $result = `/path/prog $arg`; But this doesn't work as the program is expecting and EOF that never comes. If I use the program on the command line when I am finished entering all the data I need to hit return and then CTRL-D to give an EOF. How can I simulate this using the backticks? If $arg is, what you would enter in the command line, you need to pass it to prog's stdin. You could use `echo $arg | /path/prog` for example. If $arg is more that just a single line w/o special characters, you should probably use popen for more control (is it popen in php?...) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] EOF: how to generate one in a string
$result = `echo | /path/prog $arg`; should work Jean-Christian Imbeault wrote: I am trying to use a command line program in Linux using this form: $result = `/path/prog $arg`; But this doesn't work as the program is expecting and EOF that never comes. If I use the program on the command line when I am finished entering all the data I need to hit return and then CTRL-D to give an EOF. How can I simulate this using the backticks? Thanks! Jc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] EOF: how to generate one in a string
Marek Kilimajer wrote: $result = `echo | /path/prog $arg`; should work That didn' work ... don't know why. Isn't there a way to say echo EOF? There must be a way to specify the ascii or hex value for EOF in an echo statement no? Jc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] EOF: how to generate one in a string
No, there is no such value as far as I know, you may try `/path/prog $arg somefile`, but I doubt it will be different. What prog is it anyway. If it is passwd, I know this behaves somewhat different, but I think there is still some workaround, you should as at a linux list. Jean-Christian Imbeault wrote: Marek Kilimajer wrote: $result = `echo | /path/prog $arg`; should work That didn' work ... don't know why. Isn't there a way to say echo EOF? There must be a way to specify the ascii or hex value for EOF in an echo statement no? Jc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] EOF: how to generate one in a string
Marek Kilimajer wrote: What prog is it anyway. It is a credit card processing program. It is interactive. You can it, type values in hit return, then ctrl-D and it spits out a status code. If I put all the values in a file I can get the prog to work by doing: #./prog filename It does not take any command line arguments. So I cannot just do exec prog $args since the args have to be typed in, one value per line (i.e hit return between values) and then on the last line ctrl-D ... Can anyone think of a way I can get PHP to do this short of writing to a file and the doing exec 'prog file_I_wrote'?? Jc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] EOF: how to generate one in a string
On Wednesday 08 January 2003 17:28, Jean-Christian Imbeault wrote: Marek Kilimajer wrote: $result = `echo | /path/prog $arg`; should work That didn' work ... don't know why. Isn't there a way to say echo EOF? There must be a way to specify the ascii or hex value for EOF in an echo statement no? Yes. man echo. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Patches benefit all mankind. Products benefit the vendor. - Richard Gooch on linux-kernel */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php