tonyio Posted November 18, 2014 Share Posted November 18, 2014 I need to reach Win server, scan shared folder and find out what is last created file name on this folder, and than copy this file to local folder. BUT main problem is smb, never used it before, and this is what i came up with, but no luck. require_once('smbclient.php'); $latest = null; $smbc = new smbclient ('//10.1.1.10/Share/Address Verification/', 'domain\\username', 'password'); if ($handle = opendir($smbc)) { $latest = null; while (($cur = readdir($handle) !== false)) { if ($latest == null || filectime($cur) > filectime($latest)) { $latest = $cur; } } closedir($handle); } return $latest; please help, returns Warning: opendir() expects parameter 1 to be string Quote Link to comment https://forums.phpfreaks.com/topic/292533-finding-name-of-last-created-file-on-smb-server/ Share on other sites More sharing options...
Barand Posted November 18, 2014 Share Posted November 18, 2014 $smbc is an object. You need to pass the directory path as a string Quote Link to comment https://forums.phpfreaks.com/topic/292533-finding-name-of-last-created-file-on-smb-server/#findComment-1496865 Share on other sites More sharing options...
jazzman1 Posted November 18, 2014 Share Posted November 18, 2014 also, you need to make sure that the default (139) port to this microsoft machine is opened to use: nmap -Pn -p 139 --open 10.1.1.10 nmap is a great tool. Quote Link to comment https://forums.phpfreaks.com/topic/292533-finding-name-of-last-created-file-on-smb-server/#findComment-1496868 Share on other sites More sharing options...
tonyio Posted November 18, 2014 Author Share Posted November 18, 2014 $smbc is an object. You need to pass the directory path as a string i uderstand that, how would i do that in this case? Quote Link to comment https://forums.phpfreaks.com/topic/292533-finding-name-of-last-created-file-on-smb-server/#findComment-1496890 Share on other sites More sharing options...
tonyio Posted November 18, 2014 Author Share Posted November 18, 2014 i never worked with samba, and i going mad, coz this is second day for this simple task...and i cannot solve it Quote Link to comment https://forums.phpfreaks.com/topic/292533-finding-name-of-last-created-file-on-smb-server/#findComment-1496896 Share on other sites More sharing options...
jazzman1 Posted November 19, 2014 Share Posted November 19, 2014 i never worked with samba, and i going mad, coz this is second day for this simple task...and i cannot solve it I am not familiar with this php class at all, but have experience with samba servers (by the way, actually this is not a samba server). Have you tried to establish a connection using smbclient from your Unix machine? Quote Link to comment https://forums.phpfreaks.com/topic/292533-finding-name-of-last-created-file-on-smb-server/#findComment-1496990 Share on other sites More sharing options...
tonyio Posted November 19, 2014 Author Share Posted November 19, 2014 I am not familiar with this php class at all, but have experience with samba servers (by the way, actually this is not a samba server). Have you tried to establish a connection using smbclient from your Unix machine? smbclient connection works perfectly, i use it to get files with known names, but at this case i can't know the name, i need to find name of most recent file that exist in the directory. Quote Link to comment https://forums.phpfreaks.com/topic/292533-finding-name-of-last-created-file-on-smb-server/#findComment-1497003 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.