Passing Parameter In Command Line

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

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

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?

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

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?

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

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?

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()?

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()?

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?

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?

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?

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

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?

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?

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?

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?

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?

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

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?

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

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

(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

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

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

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

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?

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?

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 ?

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?

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







Copyrights 2005-15 www.BigResource.com, All rights reserved