0

I have a scenario where I need to update the mysql database from the data in csv file. The csv file is located in FTP server instance of Marketing cloud.

$host = 'ftp.s10.exacttarget.com';
$username = 'XXXX';
$password = 'XXXX';

function scanFilesystem($dir) {
$tempArray = array();
$handle = opendir($dir);

while (false !== ($file = readdir($handle))) {
if (substr("$file", 0, 1) != "."){
       if(is_dir($file)){
        $tempArray[$file]=scanFilesystem("$dir/$file");
    } else {
        $tempArray[]=$file;
    }
}
}
closedir($handle); 
return $tempArray;
}
$SSH_CONNECTION= ssh2_connect($host, 22);
ssh2_auth_password($SSH_CONNECTION, $username, $password);
$sftp = ssh2_sftp($SSH_CONNECTION);
$dir = "ssh2.sftp://$sftp/Export";
$outgoing = scanFilesystem($dir);
sort($outgoing);
print_r($outgoing);

The above code is what I have tried till now to read the files from ftp.s10.exacttarget.com but I keep getting the error below.

Fatal error: Call to undefined function ssh2_connect()

Can anyone help me?

0

The function is undefined so it looks like the extension isn't installed. Have you installed the SSH2 PECL extension? http://php.net/book.ssh2 It isn't enabled by default.

  • Can you please help with the installation of the extension? I opened up the url but unable to locate the extension download file.@Travis – Debu Feb 26 '18 at 7:07
  • @Debu Usually these PHP extensions can be selected on the host server. Is this hosted on cPanel? If so you can add the ssh2 extension under php version. Otherwise if its local this post has more details on setting it up. stackoverflow.com/questions/15134421/… – Travis Naughton Feb 27 '18 at 0:59
  • Actually this is not hosted in Cpanel. It is in local file. Also I have tried adding php_ssh2.dll and php_ssh2.pdb files in the ext folder. Also copied libssh2.dll file to C:\Windows\system32 and (if you got Win64) C:\Windows\SysWOW64 folder. Also tried to run this command C:\> regsvr32 libssh2.dll but got this error "The module "libssh2.dll" may not compatible with the version of windows that you're running. Check if the module is compatible with an x86(32-bit) or x64(64-bit) version of regsvr32.exe" @Travis – Debu Feb 27 '18 at 5:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.