Jump to content

Recommended Posts

Hello... I would like to ask for your expert opinion.

 

I have created a small web form that will send some information via ssh2_exec() to a number of units on the filed through my WAN.

 

I created a Web form, where I request the name of the units to be sent this information to separated by a comma, and this information then is setup as the array() in the php.

 

But I am guessing that the _GET or the _POST is adding some character I cannot see to the names which causes the array to fail wen I perform the foreach()...

 

Here is the small section of code I am using...

 

 

----------------------------------

 

<?php
$nodes = $_POST['nodes'];
$script = $_POST['script'];
$hosts = array($nodes);
foreach ($hosts as $host) {
$hostname = $host;
$url = 'ltf'.$host.'.domain.com';
$con =@ssh2_connect($url, 22);
echo $nodes;
if(!($con)){
echo 'Unable to to execute connection to Remote Unit<br>';
exit(1);
}
if (!@ssh2_auth_password($con, 'admin' , 'password')){
echo 'Failed to Authenticate to Remote Unit!';
exit(1);
}
elseif (!(ssh2_exec($con, '$script'))){
echo 'Command was not executed correctly<br>';
}
echo "Connection to ".$host." was successful!<br>";
};
?>
 
 
Thank you so much in advance!
 
 
HT
Link to comment
https://forums.phpfreaks.com/topic/275611-array-data-from-form-not-working/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.