Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directory path display false as not exist although it exist with full control permission ?

Status
Not open for further replies.

ahmedsa2018

Programmer
Apr 25, 2018
67
0
0
EG
I working on script running on sql server 2019 using python 3.10 .

I have directory path \\192.168.7.9\Import\8 and can

write and read to files and delete and create files on

this directory path \\192.168.7.9\Import\8.

my issue when run script python on sql server 2019

it return false

but it must return true because directory path exist.

this path have permissions everyone and administrator and system full control read and write and delete .

script python

Python:
declare @ExportPath varchar(max)='\\192.168.7.9\Import\8'
EXEC sp_execute_external_script
@language =N'Python',
@script=N'
import os
d = os.path.isdir(ExportFilePath)
print(d)'
,@params = N'@ExportFilePath NVARCHAR(MAX)'
,@ExportFilePath = @ExportPath

Expected result is True

from sql server it return true as exist but from python script it return false for same server and same user.

correct_result_is_true_wt9j6h.png
 
are need to add user name and password
to nert use command
or no need
if required how to add
 
can you help me answer this question

if i use on python script as below
it will working
or no need to do that
i use code below to reach remote server

Python:
import paramiko

hostname = "your-hostname"
username = "your-username"
password = "your-password"
cmd = 'your-command'

try:
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(hostname,username=username,password=password)
    print("Connected to %s" % hostname)
except paramiko.AuthenticationException:
    print("Failed to connect to %s due to wrong username/password" %hostname)
    exit(1)
except Exception as e:
    print(e.message)    
    exit(2)
 
i try now to use mape network drive
it give me error 5 access is denied
using code below
Python:
import os
result = os.system("net use S: \\\\192.168.7.9\\Import\\8")
print("result =", result)
d = os.path.isdir("S:")
print("d =", d)

so i try to using domain/account name
my question i need to ask is
can access direct to remote path without using map network drive
are this possible
if possible how to do using python
Python:
import paramiko

hostname = "your-hostname"
username = "your-username"
password = "your-password"
cmd = 'your-command'

try:
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(hostname,username=username,password=password)
    print("Connected to %s" % hostname)
except paramiko.AuthenticationException:
    print("Failed to connect to %s due to wrong username/password" %hostname)
    exit(1)
except Exception as e:
    print(e.message)    
    exit(2)
are code above allow to me export data directly from remote host
please help me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top