Toogit Social Post


7 months ago
To start with, i'll say that i'm new to Perl.

I am having a few hassle passing a php argument to my perl script. The argument comes from an square question. right here's an instance and clarification of the code.

This code is used to ship the identification and retrieve the entire name of the person from the database after which ship it to the perl script so the consumer is deleted from a Fortinet wi-fi gadget.

PHP code

function deleteUser($db){
$id = $POST['param'];
$SQLq = 'delete from users where id = ?';

$q = $db->prepare($SQLq);

$data = $q->fetch();

$username = $data['user_name']; #data-type in phpmyadming : varchar
exec('perl /var/www/xxx/'.' '.escapeshellarg($id).' '.escapeshellarg($username),$output);
Here's the code from my perl script
#!/usr/bin/perl -w
use strict;
use Net::SSH::Perl;

#login info to log on the fortinet device
my $hostname = "";
my $username = "aaaa";
my $password = "xxxx";

my $userID= $ARGV[0];
my $userName = $ARGV[1];

#connection to the FORTINET device
my $ssh = Net::SSH::Perl->new($hostname);
$ssh->login($username, $password);

#string to execute
my $cmd = "config vdom \n
edit root \n
config system dhcp server \n
edit 2 \n
config reserved-address \n
delete ". $userID ." \n
end \n
end \n
config firewall address \n
delete \"" .$userName "\" \n
end \n
end \n
my($stdout,$stderr,$exit) = $ssh->cmd($cmd);
I haven't any trouble sending my identity and delete the ip reservation of the consumer from the identification sent. For some reason i can't delete the username entry from the device however if i go within the Hypertext Preprocessor code and hard code the username like this it really works flawlessly pleasant:

PHP code
$username = "test test";
i've tried a forged (string) before sending it however not anything seems to works.

So any idea on how to debug/fix this???
0 comments, 3 Followers

No comments yet!