Need assistance modifying php script

I have the following php script, from a wiki, on a Linux box that needs modification in order to work:


exec('cat /var/log/suricata/fast.log | grep "`date -d "-1 minute" "+%b %e %H:%M"`"',$lastMin); foreach($lastMin as $line) {

       if (strpos($line,"Priority: 1")!==FALSE || strpos($line,"Misc Attack")!==FALSE)
                       preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $line, $matches);
                       if (!in_array($filter, $blocked))
                               if (strpos($filter,"10.10.")!==FALSE) continue; //Protected space
			       if (strpos($filter,"64.8.")!==FALSE) continue; //Protected space
                               sendMikrotik('', 'raymond', 'password',$filter);   // Mikrotik 1

} function sendMikrotik($mt,$user,$pass,$filter) { $connection = ssh2_connect($mt); ssh2_auth_password($connection,$user,$pass); sleep(1); $stream = ssh2_exec($connection, ':global ip '.$filter); $stream = ssh2_exec($connection, '/system script run filter'); $stream = ssh2_exec($connection, 'quit'); } 

Open in new window

The script is to make a connection to my firewall and provide a list of IPs that should be blocked, based on strings it finds in a log file.

When I connect to the firewall manually, via ssh, I connect with the following command:

ssh -i /home/raymond/.ssh/id_dsa raymond@ (supply password manually)

I need to duplicate this process via the script.

I am not sure that ssh2_exec or ssh_auth_password are available; at least I could not locate them.

I am not skilled in scripting or php, so simple instructions would be appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

That's based on a PECL package.

Once you add the package, you'll have access to those ssh2_ commands.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tamray_techAuthor Commented:
OK... Got that installed:
https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip,, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp

How do I modify the ssh2 commands to connect via:
ssh -i /home/raymond/.ssh/id_dsa raymond@
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.