Find the answer to your Linux question:
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 ...
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Posts
    2

    Wink 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:
    Code:
    php -f filename.php?p={WhateverIsTyped}
    I think I made that kinda clear. It shouldnt be too hard, the only hard part should be the "applet name>" part.

    THanks in advance!

    --------------------------------------
    EDIT:
    Forgot to mention, I am using Fedora 8
    Last edited by Nitroware; 06-29-2008 at 06:49 PM. Reason: Forgot to mention...

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    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

  3. #3
    Just Joined!
    Join Date
    Jun 2008
    Posts
    2

    Lightbulb 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:
    PHP Code:
    <?
    function read()
    {
        
    $fp fopen("/dev/stdin""r");
        
    $input fgets($fp255);
        
    fclose($fp);
        return 
    eregi_replace("\n"""$input);
    }
    echo 
    "appletname > ";
    $i read();
    ?>
    Then whatever is typed goes into varible $i! That was pretty useful. Thanks for the reply though!

  4. #4
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    Don't forget to sanitise!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...