Passing Parameter In Command Line

Apr 30, 2003

Can somebody tell me how can I pass a parameter to a PHP script in de command line?
for instance: bin]# ./print_listname 18

<?php
//$list_number = // parameter var;
echo $list_number;?>

ADVERTISEMENT

Cli - Passing A String Via The Command Line

Jul 13, 2005

Ancient old crusty decided to try PHP a week or so ago. Signed up with a provider who offer PHP. Bought book. Mastering PHP.. first few pages give example of passing a string via the command line. Code:

View 4 Replies View Related

Passing $_POST Variables To Command Line Php

May 16, 2006

I'm trying to test some php script using the command line php.exe. Is there any way to pass the $_POST variables? I know how to pass the $_GET variables, but I don't know how to do this for the $_POST ones.

View 1 Replies View Related

Passing GET/POST Variables Via Command Line?

Oct 30, 2009

How does one pass GET/POST variables via command line? For instance setting $getv=100 with a command line execution of test.php.

View 8 Replies View Related

Passing $_GET, $_POST Variables To Command Line Php

Jul 17, 2005

I'm trying to test some cgi php, but do not have access to a webserver (in
any way, shape, or form). I've been trying to fudge testing by using the
CLI php.exe in the windows distribution.

I've read all the faqs about the CLI and I'm not sure if there is any way to
pass the $_GET and $_POST variables. I have yet to find any information on
this topic online, either.

If anyone has any ideas of how to do this or a better way to test, please
let me know.

View 7 Replies View Related

Command Line Interface Passing In Multiple Files?

Jan 27, 2010

I'm familiar with the basic of CLI and $argv array with php. Example:

<?php // test.php
var_dump($argv);
?>
$php test.php datafile.txt 10 100

will produce:

array(4) {
[0]=>
string(8) "test.php"
[1]=>

[Code]....

What I'm trying to do is pass all files in a directory *.txt to php. Is there way I can do $php test.php *.txt and have all the filenames stored in an array?

<?php
$files = glob($argv[1]);
?>

View 1 Replies View Related

Tracert :: Passing Command To Command Prompt Via Exec

Sep 2, 2004

I want to execute a "tracert" command in the command prompt via php (using windows)

I've managed to use passthru() to open the command prompt (but it doesn't allow me to use it) and when I close it, it outputs the command prompt output in the browser.

I don't mind whether the result is passed back to the browser to stays in the command prompt window (but that would use exec() I would think).

So how can I tell the command prompt that launches to execute the line

tracert 192.190.201.273

So far my experimental code is:

<?php
passthru("c:windowssystem32cmd.exe");
?>

EDIT: my backslashes have been stripped from the path, but you know what I mean!

View 3 Replies View Related

Linux - Executing System Command In Differs When Using Browser And When Using Command Line?

Jun 5, 2010

I have to execute a Linux more command in PHP from a particular offset, format the result and display the result in the browser.My code for the above is:

<html>
<head>
<META HTTP-EQUIV=REFRESH CONTENT=10>
<META HTTP-EQUIV=PRAGMA CONTENT=NO-CACHE>

[code]...

The output at the browser is: No of lines are : 3428 (This is wrong)While executing the same command using command line gives a different output.My code snippet for the same is:
<?php
$moreCommand = "more +3693 /var/log/apache2/access_log | grep -v -e '.jpg' -e '.jpeg' -e '.css' -e '.js' -e '.bmp' -e '.ico'| wc -l";

[code]...

The output at the command line is: No of lines are : 279 (This is correct)While executing the same command directly in command line, gives me output as 279.I am unable to understand why the output of the same command is wrong in the browser.Its actually giving the word count of lines, ignoring the offset parameter.

View 2 Replies View Related

Linux - Execute Command From Command Line But Not From PHP Exec()?

Jan 9, 2011

I have done some creative searches and am kind of hitting a road block.

I am trying to use the linux program "sox." I am trying to call it from my PHP script. The script DOES work if I use the command line. However, when I use PHP exec, it does not work.

Example:

sox file1.mp3 file2.mp3 tempfile.mp3 -V3

("V3" specifies a verbose output)

When executing in the command line as "User X" or as root, I am able to create the new file. However, when I execute the command as:

<?php
exec('sox file1.mp3 file2.mp3 tempfile.mp3 -V3', $output);
foreach($output as $line){
print $line;
}

It does not generate the new file. Furthermore, the array that should return the results of of the command is blank.

I have done a simple text with

exec(ls,$output);

and i get the contents of the root directory.

I used the PHP command get_current_user() and it returned the owner of the directory that is the root of the web site.

However, when I use the linux command whoami I found out that it views the current person as "apache." Would I need to give apache the rights to use the program?

I will continue to search online and do trial and error in an effort to figure out what I am doing wrong.

Clarifications

I am not in safe mode (I checked the
phpinfo() page")

View 3 Replies View Related

Command Works From Command Line But Not Through System(),exec()?

Mar 1, 2010

PHP script which changes the date/time and timezone.The date and time change just fine, but I cannot get the timezone to change through the script.If I type the same command at a DOS prompt it works.This only runs on a closed server (client and host are always the same) so security is not an issue.I've checked that PHP is not in safe mode and I have tried using all options to run a command that I know of (system(), exec(), shell_exec(), passthru()).This is running on XP Pro SP3.

Here is my script:
$timezone = $_POST['timezone'];
$time = $_POST['time'];
$date = $_POST['date'];

[code]...

this specific command would not work?A PHP setting?Syntax?Windows Permissions?

View 3 Replies View Related

Run An External Program In (via Command Line) Using Shel_exec Command?

Jul 21, 2010

basically i want to run an external program in PHP (via command line) and to do that i am using shel_exec command.

I understand that the shel_exec takes "String" parameter and my problem is exactly here:

I am trying to pass a variable (containing a file name) to the shel_exec, however it is not working. If I just type the content of my variable (i.e. file name) it will work but not when I am using the variable. here is the part of the code i am working in:

$output = shell_exec('java -jar C:/htmltolatex-1.0.1/htmltolatex.jar -config C:/htmltolatex-1.0.1/config.xml -output C:/ConversionTest/output.tex -input' .$pAddress);

$pAddress is my variable which I want to pass.

I have tried to print out "$pAddress" to make sure it is actually containing what I think it contains and it was fine; it DOES contain the file name, However when it is used inside the shel_exec it is not working.

View 2 Replies View Related

Use Mcrypt_decrypt From Commond Line - Error - Call To Undefined Function Mcrypt_decrypt() In Command Line Code On Line 1?

Jun 4, 2009

i m trying to use mcrypt_decrypt from commond line but i m getting the folllowing error:-

Call to undefined function mcrypt_decrypt() in Command line code on line 1

and any other alternative solution because i m using os:cmd() from erlang to achive this.since erlang do have function to achieve this but i m unable to figure out whats worng in that.so thought of doing like this so that i verify the things.

View 3 Replies View Related

Run Phpunit Command In Windows Command Line?

Feb 2, 2010

all examples of phpunit I saw run the simple command line tool:phpunit TestClass
but when I try the same on a directory other than the xampp php dir, I end up getting an "unknown command."Is there a way to execute the phpunit command from any directory in the Windows command line?

View 1 Replies View Related

CLI ( Command-line ) PHP Displaying Source Code In-line When Programis Executed

Feb 12, 2006

I'm using PHP 4.4.2, and use PHP on both the command-line and the web.

I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using
Apache 2.0.55 , on my Dell laptop. Everything has been running flawlessly
without problems. Very amazing to use VMware, it has worked beautifully.

uname -a

Linux xxxxxxx 2.6.13-15.8-default #1 Tue Feb 7 11:07:24 UTC 2006 i686 i686 i386
GNU/Linux

php -v
PHP 4.4.2 (cli) (built: Feb 7 2006 20:13:29)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

php -m

[PHP Modules]
bcmath
bz2
calendar
ctype
curl
dbx
dio
domxml
exif
ftp
gd
gettext
gmp
iconv
mcrypt
mssql
mysql
ncurses
openssl
overload
pcre
posix
session
shmop
sockets
standard
sysvsem
sysvshm
tokenizer
wddx
xml
yp
zlib

When I run the following program from the command line it prints out the
source code as well as the output from the program. I run other PHP programs
on the command-line and this doesn't happen. It's really peculiar. The
error output is below.

I copied this off of php.net, and have modified it only slightly to allow
command-line input. I was trying to find a CSV solution, which I ended up
finding elsewhere, but am curious why this program would error out the
way it does--have I misconfigured something? My php.ini is basically
unchanged, if at all. I think I might have set the path to mysql but that's
about it. When I run this program from the web it works without error.

<?php

if ( $argv[0] )
{
$file = $argv[0] ;
}
else{
$file = $_GET['file'] ;
print "<font face=arial>
" ;
}

$row = 1;

$handle = fopen("$file", "r");

while ( ( $data = fgetcsv($handle, 1000, ",") ) !== FALSE )
{

$num = count($data);

print "$num fields in line $row:<br>
";

$row++;

for ($c = 0; $c < $num; $c++)
{
print "$data[$c]<br>
" ;

View 3 Replies View Related

Output Multiple Line Command-line Outputs As Different Lines?

Jun 18, 2009

PHP: Output multiple line command-line outputs as different lines. Sorry if the title is difficult to understand. Basically I want my output like A, instead of B. It currently looks like B. I have tried nl2br. The script I am trying to run is:

Script:
echo "Virus Scan Results:";
$scanme = system('cd /var/www/upload/files; clamscan --remove=yes '.$furl);
printf(nl2br($scanme));

[Code]...

View 3 Replies View Related

Phpunit Run From Command Line Returns "'phpunit' Is Not Recognized As An Internal Or External Command Operable Program Or Batch File?

Jun 8, 2011

When I run phpunit on the command line I get 'phpunit' is not recognized as an internal or external command, operable program or batch file.

php has been added to my system path.
My php.ini includes include_path=".;C:PHPpear".

How can I get the command phpunit to be recognized by the command line?

View 2 Replies View Related

Title= Parameter In Echo Command?

Sep 30, 2009

how to do so that the parameter title= accepts a variable rather than a constant in the following :

echo '<a id="thumb'.$i.'" href="full%20('.$i.').jpg" class="highslide" onclick="return hs.expand(this)">
<img src="thumb%20('.$i.').jpg" alt="M'.$i.'" title=$libx /></a>'."

When I execute this echo, the result for title= is $libx instead of the content of $libx.

View 2 Replies View Related

Cli - Command Line Progress Bar - Add Progress Bar To Command Line Script?

Jan 23, 2010

I am currently trying to add a progress bar to a command line script and I've tried various solutions (including Zend and Console_ProgressBar). The problem they both have in common is that the progress bar doesn't stick at the bottom of the window because during the script, new lines and other information is outputted. Is there any way to keep the progress bar at the bottom of the terminal but still be able to output other information while the script is running? [Edit] I figured it out: Instead of outputting directly to STDOUT I am actually grabbing the output inside a variable, I erase the screen with echo chr(27) . '[2J' and then output to STDOUT the contents of the variable and then append my progress bar.

View 1 Replies View Related

DAL Library Which Has The Similar .Net's Feature: Command.Parameter?

Dec 24, 2009

ood DAL library for PHP which has the similar .Net's feature: ommand.Parameters.AddWithValue("@demographics", demoXml).mysqli extension is good but I want to have the aforementioned feature too. Putting many "?" does not look nice and rather confusing when a table has many fiends (>= 8).

View 1 Replies View Related

Parameter Passing From Asp To Php

Jul 17, 2005

I've got a script using com objects that will work in asp but not work
with php.

The asp script creates an object that does something and returns a
string. I want this sting to be passed to an php script without
putting it in a getstring. The getstring will expose the value and
thats not my intention. Encryption is an option but I'm not charmed by
that solution. I'd rather do it behind the scenes.

Who knows a creative way to do this?

View 3 Replies View Related

Passing A URL As A URL Parameter?

Apr 21, 2010

I am implementing OpenId login in a CakePHP application. At a certain point, I need to redirect to another action, while preserving the information about the OpenId identity, which is itself a URL (with GET parameters), for instance[URL]How do I pass this data? The first attempt would be

function openid() {
...
$this->redirect(array('controller' => 'users', 'action' => 'openid_create', $openid));

[code]...

View 3 Replies View Related

Parameter Passing

Nov 7, 2007

I am unable to pass my php parameter to the javascript. But it is not getting fetched.

<?php
$str="from php";
?>

<script>
var abc="<?php echo($str) ?>"
alert(abc);
</script>

<?php
?>

View 6 Replies View Related

Exec() Passing Parameter

Apr 20, 2003

(I have a PHP script (A) that execute in the background a another PHP script(B) and also send a parameter the $id like that:

View 3 Replies View Related

PATH_INFO Parameter Passing

Jun 10, 2001

I'm trying to work out how to pass a parameter to a PHP script so that I can use a URL as simple as: www.mysite.com/john

where "john" is actually a value to be passed to a script called index.php In other words, the full conventional URL of this would have been:

www.mysite.com/index.php?name=john

I've got as far as using the PATH_INFO environment variable to capture parameters from a URL like: www.mysite.com/index.php/john

but would like to be able to eliminate either the ".php" bit from "index.php", or the whole thing altogether. I know this is possible because I've seen plenty of sites use this URL style. I'm wondering if this involves messing with the DNS setup, which won't be possible for me as I'm running on a name-based shared server.

View 1 Replies View Related

Function Parameter Passing

Feb 26, 2007

I wrote a function that did not seem to work so
I checked whether the parameter I was passing to the function was
actually being used. I found that it wasn't. When I run the following
code I get:

Testcheck:

and nothing else. It seems that the variable is not being passed to
the function. Here is the code:

function file_write_position($textcheck) {
print "Testcheck: " . $testcheck . "<br>

";
return;
}

$testcheck="# Test Call Area";
file_write_position($testcheck);

View 3 Replies View Related

Passing Parameter Problem

Feb 8, 2007

I'm having a simple problem here. Here is a simple file test.php

<html>
<head>
<title>Parameter</title>
</head>
<body>
<?php echo "My Name is " . $name . "
"; ?>
</body>
</html>

When i try to load the file with iexplorer ---->

--->http://localhost/test.php?name=Gregory

I get the text My Name is but not Gregory. I'm running Apache2 and my php worked fine untill this.

View 3 Replies View Related

Passing A Blob As A Parameter

Jul 17, 2005

Is there a way to pass a blob field from a database to another php
script file as a parameter? The blob contains a jpeg image.

View 5 Replies View Related

Passing And URL As Parameter In Mod-rewrite?

Aug 14, 2010

I'm trying to pass an URL as a parameter in mod-rewrite. I guess there is a problem in my Regex. This my .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule **^go/((http://)+[A-Za-z0-9-]+[.A-Za-z])/?$** feedmini.php?url=$1 [L]
</IfModule>..............

View 1 Replies View Related

Passing The Parameter Using Javascript?

Jan 16, 2011

I have created an html form. it consist of several drop down list for (countries,states,cities,areas) the drop down list for countries looks like this.

Select Countries : <select name="countries" id="countries" onchange="showStates()">
<?php
foreach($crud->getAll('countries') as $countries)
{
?>
[code...]

how do i achieve it?

View 3 Replies View Related

Passing A Parameter From Javascript ?

Jul 10, 2011

I'm trying to pass a parameter to my controller.php from javascript, but it doesn't pass and gives me error of undefined URL. Here is my code

function JSfunction(assetid)
{
window.location="controller.php?command=delete&assetid=".assetid;
}

View 3 Replies View Related

Passing As The Replace Parameter?

Jul 24, 2009

An area of regular expressions that I'm not terribly familiar with:using the preg_replace function, replacing only the section of the search specified with a back reference in the replace argument(there's gotta be an easier way to say that, yeah?).The project in question is kind of a hack/filter, so by no means is it supposed to be pretty.Stripped down to the code in question, it looks something like this:what I'm passing as the replace parameter

$varstring = '<admin var="'.$vars['Var'].'" grp="'.$vars['Grp'].'"
seq="'.$vars['Seq'].'" order="'.$i.'">'.$exval[$i].'</admin>';
Here's the PCRE function
$source = preg_replace('/<connav>.*<\/connav>.*('.$ival.')/s',$varstring,$source);

[code]...

So, as I'm sure you figured out, I'm attempting to replace wherever the value of the $ival variable is found within the content of the $source variable, and replace it with the infamously ugly $varstring.Typical conventions dictate that I need simply to place a '\\1' or '$1' or '${1}' to the front of my replacement argument to serve as my backreference to the first set of parentheses in the expression, however when I run the function with any of those prependages, it continues to replace the entire content of the match with $varstring, completely ignoring my back reference(i.e. it's replacing everything between the opening<connav>tag and the end of the $ival value).

View 5 Replies View Related

Passing A Parameter In The Header (XML RPC)

Mar 16, 2010

I'm trying to set up a server status for the MMORPG Champions Online. I got some basic information from the web master and this is all he told me:

XML-RPC call to server: http://www.champions-online.com/xmlrpc.php
function name: wgsLauncher.getServerStatus
Parameter (language): en-US

Now, I found a nice example to start with here, and I ended up with this code:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
# Using the XML-RPC extension to format the XML package

[Code]...

Note: My host supports xmlrpc but it seems the function "xmlrpc_client" doesn't exist.

Update: The web master replied with this information, but it's still not working... it's getting to the point I may just scrape the status off the page.

$request = xmlrpc_encode_request("wgsLauncher.getServerStatus", "en-US" );

View 1 Replies View Related

Parameter Passing B/w Two Site

Nov 24, 2007

i need to pass one parameter from one website to another.

View 1 Replies View Related

Passing A Parameter In A Link?

Jan 8, 2010

why the following code is not working correctly? The scenerio is that the variable $business_name = "teeth fixes" it only gets the first word and not the entire phrase. If I do "teeth_fixes" then it will get the entire phrase. For some reason when it hits the space it cuts the rest off. The same variable business name just before the "</a>" in the link has the whole name just fine, it has something to do with the param function i guess?? I even tried to do the link different like this:

Code: [Select]echo"<tr>
<td><a href=show_coupon.php?business=".$business_name.">$business_name</a>
<td>
</tr>";

But that did not seem to work either.Here is the code that is breaking the words. Not sure why or how to fix it

Code: [Select]while ($row = mysql_fetch_array($cat_coupons))
{
$business_name = $row["business_name"];[code].....

View 3 Replies View Related

Passing Parameter Within Redirect?

Jan 8, 2011

i short, I have an application that has a link that goes to:

Site1/dir/admin?id=(text)&page=(number)

I want to redirect to a link that's identical except it's Site2 at the beginning instead of Site 1.

What I've attempted so far is this:

<?php

$GLOBALS[$passid]=$_GET['id'];
$GLOBALS[$passpage]=$_GET['page'][code]....

I have a feeling I'm doing something small but very basic wrong.The $GLOBALS thing was an afterthought. Outcome is the same with or without that.

View 4 Replies View Related

Simplified Url Parameter Passing?

Nov 1, 2009

I'd like for users to be able to pass URL parameters simply, for example instead of[url]..... I'd like to allow them to type [url]....I've seen this done on a few sites, and wonder whether there's some way for PHP to process it? Would this method involve .htaccess, etc.? Maybe it intercepts 404 error conditions?

View 2 Replies View Related

Passing Along The Product Id As A Parameter?

May 4, 2011

i have a simple database made up with a product table with five fields; id, url, name, description, and price. also a categories table with five fields; id, parent_id, siteurl, name, and description. i have everything up and running,but i can't figure out how to pass the product id as a parameter. right now i have "example.php" but i need "example.php?id=1" here is what my code looks like

indextest.php

Code: [Select]

<?php
error_reporting(0);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

[code].....

i know i probably have a lot of problems with this code, but the one i can't figure out is passing the parameter and i have been looking at forums, websites, w3schools, everywhere. i;m just not grasping the concept of how to make it work with this.

View 4 Replies View Related

Passing A Reference To A Function As A Parameter?

Mar 2, 2007

I'm writing a class that accepts a SQL query and outputs an HTML table of the results. It's designed so you can do some pretty extensive formatting of individual columns.

I'd like to give the user the ability to process particular column data with a custom function handler - for example, they might want to process a field that contains a dollar amount by running it through a function that prepends a dollar sign and inserts commas between grouped thousands. Something like this:

$foo = new MyClass();
$foo->addCustomHandler( 'column_name', [specify handler function here] );

Currently, the class user passes in the name of the handler function as a string, and the class invokes it with eval(). This works, but using eval() makes my skin crawl - it's just not an elegant way to do things.

In JavaScript, functions are objects, so you can pass them around and reference them like any other variable, but that's not the case in PHP.

View 3 Replies View Related

Passing Parameter While Including Script?

Apr 1, 2011

I want to do this, but it gives error :( for better understanding my problem I'm giving an example:

<?php
include 'script.php?text=hiii';
?>

content of the script.php

<?php
echo $_GET['text'];
?>

So, how can i pass an argument while including the script page?

View 3 Replies View Related

Passing Multiple Parameter From Javascript

Oct 21, 2009

i am trying to Use this

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
function CallSomePHP()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="myPhp.php"; ***(Need to Pass multiple parameter to php from here)***
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
alert(xmlhttp.responseText);

View 2 Replies View Related

Passing Search Parameter Through Jquery?

Jul 26, 2010

i have a form in which if the user enters the search query, its parameter should be passed through jquery and after getting the results it should load the results in the div container. since i'm not very well-versed with jquery, how would i do this?

html:

//currently the data is being displayed on pageload:
$(document).ready(function() {
$("#bquote").load("quotes_in.php")
});................

View 3 Replies View Related

Call The Function According To A Passing Parameter?

Feb 16, 2010

I have a class 'abc', with several functions inside it:
'abc_function1'
'abc_function2'
'abc_function3'
'abc_function4'
'abc_function5'

I would like to call a function of the class 'abc' according to a parameter that I enter, a string containing 'function1' or 'function 4' for example, to refer to the corresponding function of the class.

View 3 Replies View Related

Ajax: Parameter Passing Not Working On IE?

Jun 4, 2009

I have this simple code to test something:


Code:
<?php
if (isset($_POST['c'])){
echo $_POST["c"];

[code]....

It works flawlessly on Firefox, but on IE, the php is not receiving any parameter ($_POST['c'] is empty always). I tried both POST and GET methods.

View 1 Replies View Related

Java: Passing A Map As A Function Parameter?

Jul 3, 2011

I'm new to Java, and need to know how to pass an associative array (Map) as a single parameter in a function.

Here's what I'm wanting to do in Java, shown in PHP.

<?php
public class exampleClass {
public function exampleFunction($exampleParam){
if(isset($exampleParam['exampleKey'])){
return true;

[Code]....

View 2 Replies View Related

Prevent Passing Down Of Parameter From One Function To Another?

Aug 27, 2009

Example:

Class A {
public function __construct() {
$this->b_Instance = new B();
}
public caller() {

[Code]....

Normally I'd add it to the constructor of B as a class variable, however the constructor is already populated with lots of variables, and the parameters passed by A->caller() is only used by B->call_me and B->do_something anyway.

What is the elegant way of preventing this extra-passing of parameters from B->call_me to B->do_something? Or is this even a problem and I just have OCD?

Additional: Notice that B->call_me does nothing with param2 and 3, but only passes it to B->do_something which is a private function.

View 2 Replies View Related

ADVERTISEMENT