Jump to content

passing arguments


ub007

Recommended Posts

Hi,

 

I got a python program that runs with the foll arguments

 

python load.py http://www.example.com 5 2 2

i supply the 4 args through this form

 

SERVER(enter in the format 'www.example.com'): <input type="text" name="server" /><br />
AGENT: <input type="text" name="threads" /><br />
INTERVAL: <input type="text" name="interval" /><br />
RAMPUP: <input type="text" name="rampup" /><br />

 

i get the values here:

$servername = $_GET['server'];
$agents = $_GET['threads'];
$timeinterval = $_GET['interval'];
$ramp = $_GET['rampup'];

 

 

$stream = ssh2_exec($con, 'python /home/leo/Desktop/pylo.py .$servername .$agents .$timeinterval .$ramp')

 

This doesnt work

sometimes theres no output and when i fiddle around with the spaces or commas i get

parse error, unexpected T_CONSTANT_ENCAPSED_STRING,

something like $stream = ssh2_exec($con, 'python /home/leo/Desktop/hello.py) runs perfectly fine

 

 

PLz help

Link to comment
https://forums.phpfreaks.com/topic/122283-passing-arguments/
Share on other sites

Just noticed this:

$stream = ssh2_exec($con, 'python /home/leo/Desktop/pylo.py .$servername .$agents .$timeinterval .$ramp')

 

that should be:

$stream = ssh2_exec($con, "python /home/leo/Desktop/pylo.py $servername $agents $timeinterval $ramp")

 

Variables return their values only in double quotes, not in single ones and there's no need to concatenate variables which are inside quotes. To give the idea:

<?php
$site = 'phpfreaks';
echo 'This site is: $site'; //will print: This site is: $site
echo "This site is: $site"; //will print: This site is: phpfreaks
echo "This site is: . $site"; //will print: This site is: . phpfreaks
echo 'This site is:' . $site; //will print: This site is: phpfreaks
?>

Link to comment
https://forums.phpfreaks.com/topic/122283-passing-arguments/#findComment-631501
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.