Results 1 to 4 of 4
Ok, I am writing a linux CLI interface that I want to work with PHP. I dont know "The way of the shell programmer", but I dont need to that ...
- 06-29-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 2
A super easy question
Ok, I am writing a linux CLI interface that I want to work with PHP. I dont know "The way of the shell programmer", but I dont need to that badly. My question is, i want to be able to do this
appletname -connect
Then it will open up
applet name>{WhateverIsTyped}
And i will be able to use the script that way. However, what I will do is pass everything typed to a php file like so:
I think I made that kinda clear. It shouldnt be too hard, the only hard part should be the "applet name>" part.Code:php -f filename.php?p={WhateverIsTyped}
THanks in advance!
--------------------------------------
EDIT:
Forgot to mention, I am using Fedora 8Last edited by Nitroware; 06-29-2008 at 06:49 PM. Reason: Forgot to mention...
- 06-30-2008 #2
Well, where are you so far with this? You will certainly need some Bash knowledge if you're planning to write this in Bash, but you could really do this in any language.
Basically, you will need to be able to take the first input, and from that, determine the appletname. You will then need some way of associating this appletname with the PHP file, so that you can know that it's a valid PHP script and what to execute.
Now that you've verified the PHP script, you just need to capture the next input and then execute php in the manner that you've specified.
This doesn't seem too particularly difficult, so where exactly are you having problems?
Also note that "applet" generally refers to a Java applet, so it may not be the terminology that you meant to use.DISTRO=Arch
Registered Linux User #388732
- 06-30-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 2
Re:
Whoa... I need to update my "lingo". Anyway. Thanks for the reply, but I found a much easier way, using entirely PHP (accept for "php -f <filename>"). Anyway, what I did was use this code so that I tlooks like the mysql "terminal" I think its called, but really its a never ending loop usinf this function:
Then whatever is typed goes into varible $i! That was pretty useful. Thanks for the reply though!PHP Code:<?
function read()
{
$fp = fopen("/dev/stdin", "r");
$input = fgets($fp, 255);
fclose($fp);
return eregi_replace("\n", "", $input);
}
echo "appletname > ";
$i = read();
?>
- 06-30-2008 #4Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110


Reply With Quote
