You are here: Re: 'echo "": No such file or directory" error using "exec" to pipe in PHP script « All PHP « IT news, forums, messages
Re: 'echo "": No such file or directory" error using "exec" to pipe in PHP script

Posted by Bryan Oakley on 12/01/06 17:02

comp.lang.tcl wrote:
> [TCL]
>
> set php {<? print_r("Hello World"); ?>}
> puts $php; # PRINTS OUT <? print_r("Hello World"); ?>
> puts [exec "echo '$php' | php -q"]
>
> [/TCL]
>
> When I try this within TCL I get the following error:
>
> [quote]
> echo "": No such file or directory
> [/quote]
>

"echo" is not a command you can exec. It is a "built-in" -- a command
known only to the shell that implements it. Think of it more as a
subcommand of sh/bash/ash/tcsh/etc. Much like those commands don't know
about "proc".

You need to understand that 'exec' simply runs a file given to it as the
first argument. It does a couple of shortcuts such as looking for the
file within the directories in the PATH environment variable, and will
look for both "foo.exe" and "foo" on windows. But the fact remains, it
is a way to spawn the execution of a file rather than a command line.

If you're wanting to exec php and give it the contents of a variable on
stdin, try this:

puts [exec php << $php]

You need to make sure that "php" is a valid command file on your
machine, and that its location is in your PATH environment variable.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация