Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not use command line interpreter

I have tried to execute simple php code in the php interpreter. When I executed the command php -a I getting the message

Interactive mode enabled

Without any place for php input. But I can execute a php code through the command php -r. for example:

php -r "echo 'Hello stackoverflow!';"

Hello stackoverflow!

like image 415
user1341970 Avatar asked Apr 23 '12 15:04

user1341970


People also ask

What is the interpreter in command line?

A command interpreter is the part of a computer operating system that understands and executes commands that are entered interactively by a human being or from a program. In some operating systems, the command interpreter is called the shell.

Is a command-line interpreter application available in most Windows OS?

Command Prompt is a command line interpreter application available in most Windows operating systems. It's used to execute entered commands. Most of those commands automate tasks via scripts and batch files, perform advanced administrative functions, and troubleshoot or solve certain kinds of Windows issues.

Which is an example of command-line interpreter?

Examples of command-line interpreters include DEC's DIGITAL Command Language (DCL) in OpenVMS and RSX-11, the various Unix shells (sh, ksh, csh, tcsh, zsh, Bash, etc.), CP/M's CCP, DOS' COMMAND.COM, as well as the OS/2 and the Windows CMD.

How does a command-line interpreter work?

It's literally an interpreter of commands. Unlike a program that has a graphical user interface (GUI) like buttons and menus that are controlled by a mouse, a command line interpreter accepts lines of text from a keyboard as the commands and then converts those commands into functions that the OS understands.


2 Answers

Install this:

php5-readline

then try use:

php -a
like image 107
lensanag Avatar answered Sep 30 '22 18:09

lensanag


type php -m and make sure you have the readline module. If you don't you won't be able to use it.

http://www.php.net/manual/en/features.commandline.interactive.php

As of PHP 5.1.0, the CLI SAPI provides an interactive shell using the -a option if PHP is compiled with the --with-readline option.

like image 20
craniumonempty Avatar answered Sep 30 '22 16:09

craniumonempty