简体   繁体   中英

Perl script to access all user account directories on Linux server

I have a dedicated Linux web server with many user accounts on it. The user accounts are all located in /home/[userid] directories. I am able to create Perl scripts that run within each of my users' accounts that can access files only within their own account, but now I need to create a script that can run “above” the users' accounts and be able to access a file within any specified user's account.

Currently, I have a script that uses Net::FTP to retrieve the needed file from each account so I can extract the necessary data from it, but of course, it's slow to FTP into every account. Since the accounts are merely directories on the server, I'm looking for a way to run a Perl script in a way that it can access each account directory and simply open the required file and return the requested data for the specified account.

How can I accomplish this?

You should login as a user that has access to all the user directories (eg root ). For security reasons, it might be safer to use sftp or some other encrypted connection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM