Advertisement

03.18.2008 at 05:33PM PDT, ID: 23252278
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Problems with returning results (perl/php)

Asked by Simon336697 in PHP Scripting Language, Perl Programming Language, PHP and Databases

Hi everyone hope u can help.

The following command I can run from a command line no problem at all.

-------------------------------------------------------------------------------------------- From a command line:

C:\wamp\www>perl datacenterlisting.pl --server "serverA" --datacenter "datacenterA" --username "domain\userA" --password "password"

What the output returns from above is the following....................................... Output:

Hosts found:
1: hostA
2: hostB
3: hostC
etc etc

VM's found:
1: machineAvm
2: machineBvm
2: machineBvm
3: machineCvm
4: machineDvm
etc etc
---------------------------------- End of output.

What Im trying to do is to execute the command from a web page using php and perl.

I have ActiveState Perl and PHP 5, and my current web page layout is as follows...........

--------------------------------------------------------------------------------------- Test.php
VC Server:  _________________

Datacenter/s:  DatacenterA [  ]        DatacenterB [  ]        DatacenterC  [  ]

Username:  _____________________

Password:  _____________________

<Show Listing button>

------------------------------------------------ Comments about Test.php
In the above, I do the following on the page...

- I enter in a server name in the 'VC Server' textbox
- I select what datacenters I want to run the perl script against by checking the radio buttons next to Datacenter/s:
- I enter in the username in the format:   <somain>\<username>
- I enter in a password.
- Then I click on the Show Listing submit button.
This then executes a perl command (the same one that I previously did from a command line), and takes the POSTED values from the form as parameters to pass to this perl command.

When I do this, all Im getting at the moment, is just the following output when doing this through a php page....

------------------------------------------------------------------- Current output through Test.php

DatacenterA
perl c:\datacenterlisting.pl --server "serverA" --datacenter "DatacenterA" --username "domainusername" --password "password"

As you can see from the above, the output is just displaying the command, but not returning any results.
Part of the problem seems to be the username "domainusername".
I submitted this as domain\username, but as you can see from above, it says "domainusername" with no backslash.
Even if I enter 2 backslashes, the output "looks" correct, as the following shows, but im not getting any results returned in the page, other than...

perl c:\datacenterlisting.pl --server "serverA" --datacenter "DatacenterA" --username "domain\username" --password "password"

instead of what I require, which would be something like.......

perl c:\datacenterlisting.pl --server "serverA" --datacenter "DatacenterA" --username "domain\username" --password "password"

Hosts found:
1: hostA
2: hostB
3: hostC
etc etc

VM's found:
1: machineAvm
2: machineBvm
2: machineBvm
3: machineCvm
4: machineDvm
etc etc
---------------------------------- End of output.

Guys here is my current code.
If you could kindly help me find out why the script is not executing like it is at a command line, and returning results, Id be most appreciative :>)

--------------------------------------------------------------------------------------------------- Test.php

<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>">
<b>VC Server:</b>
<input type="text" name="server" value="<?php echo htmlspecialchars(@$_POST['server']); ?>" /><br/><br>
<div style="background:silver; margin-top:5px; border:solid 1px black;"> <b>Datacenter/s:</b>  
datacenterA: <input type="checkbox" name="chkdc[]" value="datacenterA">  
datacenterB: <input type="checkbox" name="chkdc[]" value="datacenterB">  
datacenterC: <input type="checkbox" name="chkdc[]" value="datacenterC">  
</div><br>
Username: <input type="text" name="username" value="<?php echo htmlspecialchars(@$_POST['username']); ?>" /><br/>
Password: <input type="password" name="password" /><br/> <input type="submit" name="Submit" value="show listing" />  
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST' && strval($_POST['Submit'])=="show listing") {
      $dataCenter=$_POST['chkdc'];
      foreach($dataCenter as $k => $v)
      {
        $shellStr = sprintf(
                'perl c:\datacenterlisting.pl --server "%s" --datacenter "%s" --username "%s" --password "%s"',
                $_POST['server'],$v,
                stripslashes($_POST['username']),
                $_POST['password']
                    );
            echo 'Results:<pre>'.htmlspecialchars(shell_exec($shellStr)).'</pre>';
            echo $v;
            echo '<br>';
            echo $shellStr;
      }
      echo " <input type='submit' name='refresh' value='Refresh' />";
}
?>
</form>

---------------------------------------------------------------------------------------------Start Free Trial
[+][-]03.18.2008 at 05:50PM PDT, ID: 21157618

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 05:53PM PDT, ID: 21157636

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Perl Programming Language, PHP and Databases
Sign Up Now!
Solution Provided By: karlwilbur
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03.18.2008 at 06:05PM PDT, ID: 21157687

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03.18.2008 at 06:57PM PDT, ID: 21157876

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:00PM PDT, ID: 21157890

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:04PM PDT, ID: 21157909

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:09PM PDT, ID: 21157936

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:12PM PDT, ID: 21157945

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:12PM PDT, ID: 21157946

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:14PM PDT, ID: 21157951

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:16PM PDT, ID: 21157960

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:26PM PDT, ID: 21158011

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:27PM PDT, ID: 21158015

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:28PM PDT, ID: 21158017

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:28PM PDT, ID: 21158021

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:29PM PDT, ID: 21158028

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:31PM PDT, ID: 21158033

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:32PM PDT, ID: 21158040

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:35PM PDT, ID: 21158056

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 07:37PM PDT, ID: 21158065

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 08:08PM PDT, ID: 21158182

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 05:19AM PDT, ID: 21160667

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.22.2008 at 04:48PM PDT, ID: 21188116

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628