0

Read a file with sensetalk smb protocol Is this correct?

put "username" into username put "password" into password put "server_name" into serverName put "path/to/file.txt" into filePath

Create an SMBConnection object

put SMBConnection(username, password, "client_name", serverName, use_ntlm_v2:true) into conn

Connect to the server

put conn.connect("server_ip", 139) into connStatus

Check if the connection was successful

if connStatus is not "SUCCESS" then logError "Failed to connect to server: " & connStatus else # Read the file put conn.openFile(filePath, "r") into fileObj put fileObj.read() into fileData

# Print the file contents
log fileData

# Close the file and the connection
fileObj.close()
conn.close()

end if

////write to a file put "username" into username put "password" into password put "server_name" into serverName put "path/to/file.txt" into filePath

Create an SMBConnection object

put SMBConnection(username, password, "client_name", serverName, use_ntlm_v2:true) into conn

Connect to the server

put conn.connect("server_ip", 139) into connStatus

Check if the connection was successful

if connStatus is not "SUCCESS" then logError "Failed to connect to server: " & connStatus else # Write to the file put conn.openFile(filePath, "w") into fileObj put "This is some text that we're writing to the file" into fileData fileObj.write(fileData)

# Close the file and the connection
fileObj.close()
conn.close()

end if

To read a file on a network drive with this method.

maseyh
  • 11
  • 2

0 Answers0