LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Is there something that can transform a program made with php to shell-script? (https://www.linuxquestions.org/questions/programming-9/is-there-something-that-can-transform-a-program-made-with-php-to-shell-script-409947/)

stormrider_may 01-31-2006 05:52 AM

Is there something that can transform a program made with php to shell-script?
 
I would to know if there is a program that can transform a source originally made with php to shell-script?
I think the problem is the html, forms and thinks like this. I almost didn't used javascript, so i think this would not be a problem.

Guttorm 01-31-2006 07:06 AM

Hi

I often write shell scripts, and since i'm confortable with PHP i prefer it to bash and the likes.

On Debian first
apt-get install php4-cli
Note it installs a separate php.ini file you might want to edit.

Then just prefix your scripts with path to php, like e.g.
#!/usr/bin/php
<?php
echo "Hi there";
?>

Make the file executable, and you have a shell script.

Hope this helps,
Guttorm.

stormrider_may 01-31-2006 08:56 AM

But, how about forms and thinks like this. Will it appear?

Guttorm 01-31-2006 09:12 AM

When you execute the shell script, it will display HTML, if that's what the program outputs.

Shell scripts are usually not very user interactive - I don't think I understand what you're trying to do. If you need HTML rendering, I dont think there's another way except thru a web-server and using a browser. It would be possible to output the HTML and then get the HTML rendered in a web-broswser, but is that really a shell-script?

If you need a lot of interactivety, you need to rewrite everything that has to do with output and input from the users. I suggest looking into ncurses, http://www.php.net/manual/en/ref.ncurses.php

xhi 01-31-2006 10:59 AM

you can interact with STDIN like you would a normal file.. somthing like this..
Code:

$input = fread(STDIN, $buffer_size);
as Guttorm said.. you cant render html without a browser.. if this is to be all command line maybe you could use lynx to dispay your html.. or forget the html all together..

http://us3.php.net/features.commandline
and google on php cli


All times are GMT -5. The time now is 06:32 AM.