Avatar of czutshi
czutshi
 asked on

how to connect the linux server using python script

My reqirement is to count the total number of files and subdirectories under a specific path from the two different server using PYTHON. (Both server are linux)

I dunno to connect to server using PYTHON.

Can anyone please give solution?

Here I have written my code for your reference





import os
dircnt=0
filecnt=0
for root, dirs, files in os.walk('/home/webdocs/wind2_documents'):
    dircnt += len(dirs)
    filecnt += len(files)
 
print dircnt
print filecnt

Open in new window

Linux OS Dev

Avatar of undefined
Last Comment
HonorGod

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Duncan Roe

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
HonorGod

Can you "mount" the remote directory on a local mount point?
This would make the solution trivial...
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes